<?php

declare(strict_types=1);

namespace Seka\Portal\Modul\Terminy\Entities\Udalost;

/**
 * Enum StavUdalosti
 *
 * @package Seka\Portal\Modul\Terminy\Entities\Udalost
 */
enum StavUdalosti: string
{
    case ZVEREJNENA = 'ZVEREJNENA';
    case NEZVEREJNENA = 'NEZVEREJNENA';

    /**
     * @param string $name
     *
     * @return self|null
     */
    public static function fromName(string $name): ?self
    {
        foreach (self::cases() as $case) {
            if ($case->name === $name) {
                return $case;
            }
        }

        return null;
    }

    /**
     * @return string
     */
    public function label(): string
    {
        return match ($this) {
            self::ZVEREJNENA => 'zverejnená',
            self::NEZVEREJNENA => 'nezverejnená',
        };
    }

    /**
     * @return string
     */
    public function color(): string
    {
        return match ($this) {
            self::ZVEREJNENA => '#adbadd',
            self::NEZVEREJNENA => '#c0d1d8',
        };
    }

    /**
     * @param \Seka\Portal\Modul\Terminy\Entities\Udalost\StavUdalosti $other
     *
     * @return bool
     */
    public function equal(self $other): bool
    {
        return $this == $other;
    }
}
