Added method \TamerLib\Classes > Validate > getObjectType()
This commit is contained in:
parent
ae1ed3460a
commit
2aae9d3929
1 changed files with 28 additions and 0 deletions
|
@ -3,6 +3,7 @@
|
||||||
namespace TamerLib\Classes;
|
namespace TamerLib\Classes;
|
||||||
|
|
||||||
use TamerLib\Abstracts\Mode;
|
use TamerLib\Abstracts\Mode;
|
||||||
|
use TamerLib\Abstracts\ObjectType;
|
||||||
use TamerLib\Abstracts\ProtocolType;
|
use TamerLib\Abstracts\ProtocolType;
|
||||||
use TamerLib\Abstracts\TaskPriority;
|
use TamerLib\Abstracts\TaskPriority;
|
||||||
|
|
||||||
|
@ -50,4 +51,31 @@
|
||||||
default => false,
|
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,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue