<?php

declare(strict_types=1);

namespace App\Entity;

enum EventDateStatus: string 
{
    case PENDING   = 'pending'; 
    case CANCELLED = 'cancelled'; 
    case DONE      = 'done'; 
    case UNKNOWN   = 'unknown'; 

    public static function combine(self $src, self $dst) {

        if ($src == $dst) return $src;

        switch ($src) {
            case self::UNKNOWN:
                return $dst;
            case self::PENDING:
                switch ($dst) {

                    case self::UNKNOWN:
                    case self::PENDING:
                        return $src;

                    case self::CANCELLED:
                    case self::DONE:
                        return $dst;

                    default:
                        return $src;
                }
            case self::DONE:
            case self::CANCELLED:
                return $src;

            default:
                return $src;
        }
   }

   public static function toEventStatus(self $status) {
    switch ($status) {
        case self::UNKNOWN:   return EventStatus::UNKNOWN;
        case self::PENDING:   return EventStatus::PENDING;
        case self::CANCELLED: return EventStatus::CANCELLED;
        case self::DONE:      return EventStatus::DONE;
        default:              return $status;
    }
}
}