2023-11-27 22:39:35 +04:00
|
|
|
<?php
|
2024-05-23 08:15:28 +04:00
|
|
|
namespace nur\sery\wip\schema;
|
2023-11-27 22:39:35 +04:00
|
|
|
|
2024-05-23 08:15:28 +04:00
|
|
|
use nur\sery\wip\schema\types\IType;
|
|
|
|
use nur\sery\wip\schema\types\Registry;
|
|
|
|
use nur\sery\wip\schema\types\tarray;
|
|
|
|
use nur\sery\wip\schema\types\tbool;
|
|
|
|
use nur\sery\wip\schema\types\tcallable;
|
|
|
|
use nur\sery\wip\schema\types\tfloat;
|
|
|
|
use nur\sery\wip\schema\types\tint;
|
|
|
|
use nur\sery\wip\schema\types\tstring;
|
2023-11-27 22:39:35 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class types: classe outil pour gérer le registre de types
|
|
|
|
*/
|
|
|
|
class types {
|
|
|
|
/** @var Registry */
|
|
|
|
private static $registry;
|
|
|
|
|
|
|
|
static function registry(): Registry {
|
|
|
|
if (self::$registry === null) {
|
|
|
|
self::$registry = new Registry();
|
|
|
|
}
|
|
|
|
return self::$registry;
|
|
|
|
}
|
|
|
|
|
|
|
|
static function get(string $name): IType {
|
|
|
|
return self::registry()->get($name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static function string(): tstring { return self::get("string"); }
|
|
|
|
static function bool(): tbool { return self::get("bool"); }
|
|
|
|
static function int(): tint { return self::get("int"); }
|
|
|
|
static function float(): tfloat { return self::get("float"); }
|
|
|
|
static function array(): tarray { return self::get("array"); }
|
|
|
|
static function callable(): tcallable { return self::get("callable"); }
|
|
|
|
}
|