1 | <?php |
||
19 | abstract class Type implements TypeInterface |
||
20 | { |
||
21 | use Serializable; |
||
22 | |||
23 | /** |
||
24 | * @var Type[] |
||
25 | */ |
||
26 | private static $instances = []; |
||
27 | |||
28 | /** |
||
29 | * @var array |
||
30 | */ |
||
31 | private static $types = []; |
||
32 | |||
33 | /** |
||
34 | * @var string |
||
35 | */ |
||
36 | protected $name; |
||
37 | |||
38 | /** |
||
39 | * BaseType constructor. |
||
40 | * @param string $name |
||
41 | */ |
||
42 | public function __construct(string $name) |
||
46 | |||
47 | /** |
||
48 | * @param string $type |
||
49 | * @return Type |
||
50 | */ |
||
51 | public static function of(string $type): Type |
||
57 | |||
58 | /** |
||
59 | * @return string |
||
60 | */ |
||
61 | public function getName(): string |
||
65 | |||
66 | /** |
||
67 | * @param TypeInterface $type |
||
68 | * @return bool |
||
69 | */ |
||
70 | public function instanceOf(TypeInterface $type): bool |
||
74 | |||
75 | /** |
||
76 | * @return string |
||
77 | */ |
||
78 | public function __toString(): string |
||
82 | |||
83 | /** |
||
84 | * @param string $name |
||
85 | * @return bool |
||
86 | * @throws \ReflectionException |
||
87 | */ |
||
88 | public static function isValid(string $name): bool |
||
100 | } |
||
101 |