*/ declare(strict_types = 1); /** * Represents a higher level category of event types. */ enum MDEventCategory implements JsonSerializable { case production; case post_production; case pre_production; case no_production; /** * Returns an MDEventCategory based on a given event type. * * @param integer $event_type Event type. * * @return MDEventCategory */ public static function fromEventType(int $event_type):MDEventCategory { if (in_array($event_type, MDEventsSet::EVENTS_PRODUCTION, true)) { return self::production; } if (in_array($event_type, MDEventsSet::EVENTS_POST_PRODUCTION, true)) { return self::post_production; } if (in_array($event_type, MDEventsSet::EVENTS_PRE_PRODUCTION, true)) { return self::pre_production; } if (in_array($event_type, MDEventsSet::EVENTS_NO_PRODUCTION, true)) { return self::no_production; } if ($event_type === 5 || $event_type === 36) { // Was depicted (actor + place) return self::no_production; } throw new Exception("Uncategorized event type: " . $event_type); } /** * Lists all available names. * * @return array */ public static function caseNames():array { $output = []; $cases = self::cases(); foreach ($cases as $case) { $output[] = $case->name; } return $output; } /** * Provides the option to serialize as a string during json_encode(). * * @return string */ public function jsonSerialize():string { return $this->name; } }