<?php

namespace App\Enums;

enum PublishStatusEnum: string
{
    case UNPUBLISHED = 'unpublished';
    case PUBLISHING = 'publishing';
    case PUBLISHED = 'published';
    case SKIPPED = 'skipped';
    case ERROR = 'error';

    /** Skipped articles were never attempted, so they are not a publish outcome. */
    public function isSettled(): bool
    {
        return $this === self::PUBLISHED || $this === self::ERROR;
    }

    /**
     * @return array<int, string>
     */
    public static function settledValues(): array
    {
        return array_values(array_map(
            fn (self $status): string => $status->value,
            array_filter(self::cases(), fn (self $status): bool => $status->isSettled()),
        ));
    }
}
