<?php

declare(strict_types=1);

namespace App\Entity;

enum EventStatus: string 
{
    case UNKNOWN     = 'unknown'; 
    case PENDING     = 'pending'; 
    case IN_PROGRESS = 'in-progress'; 
    case DONE        = 'done'; 
    case CANCELLED   = 'cancelled'; 

    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::IN_PROGRESS:
                    case self::CANCELLED:
                    case self::DONE:
                        return $dst;

                    default:
                        return $src;
                }
            case self::IN_PROGRESS:
                switch ($dst) {

                    case self::UNKNOWN:
                    case self::PENDING:
                    case self::IN_PROGRESS:
                        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 combineWithDateStatus(self $src, EventDateStatus $dst) {

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

        case self::PENDING:
            switch ($dst) {

                case EventDateStatus::UNKNOWN:
                case EventDateStatus::PENDING:
                case EventDateStatus::CANCELLED:
                    return $src;

                case EventDateStatus::DONE:
                    return self::IN_PROGRESS;

                default:
                    return $src;
            }
        case self::IN_PROGRESS:
            return $src;
        case self::DONE:
            switch ($dst) {

                case EventDateStatus::UNKNOWN:
                case EventDateStatus::CANCELLED:
                case EventDateStatus::DONE:
                    return $src;

                case EventDateStatus::PENDING:
                    return self::IN_PROGRESS;

                default:
                    return $src;
            }
        case self::CANCELLED:
            switch ($dst) {

                case EventDateStatus::UNKNOWN:
                case EventDateStatus::CANCELLED:
                    return $src;

                case EventDateStatus::PENDING:
                case EventDateStatus::DONE:
                    return EventDateStatus::toEventStatus($dst);

                default:
                    return $src;
            }

        default:
            return $src;
    }
}

}