diff --git a/src/TamerLib/Classes/Validate.php b/src/TamerLib/Classes/Validate.php index f292c38..440e887 100644 --- a/src/TamerLib/Classes/Validate.php +++ b/src/TamerLib/Classes/Validate.php @@ -3,6 +3,7 @@ namespace TamerLib\Classes; use TamerLib\Abstracts\Mode; + use TamerLib\Abstracts\ObjectType; use TamerLib\Abstracts\ProtocolType; use TamerLib\Abstracts\TaskPriority; @@ -50,4 +51,31 @@ default => false, }; } + + + /** + * Determines the object type + * + * @param $input + * @return string + */ + public static function getObjectType($input): string + { + if(!is_array($input)) + { + return ObjectType::Unknown; + } + + if(!array_key_exists('type', $input)) + { + return ObjectType::Unknown; + } + + return match ($input['type']) + { + ObjectType::Job => ObjectType::Job, + ObjectType::JobResults => ObjectType::JobResults, + default => ObjectType::Unknown, + }; + } } \ No newline at end of file