1 | <?php |
||
16 | class Type { |
||
17 | |||
18 | /** |
||
19 | * Type to validate against. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | private $type; |
||
24 | |||
25 | /** |
||
26 | * Type constructor. |
||
27 | * |
||
28 | * @param string $type |
||
29 | */ |
||
30 | public function __construct( $type ) { |
||
33 | |||
34 | /** |
||
35 | * Get validation type. |
||
36 | * |
||
37 | * @return string |
||
38 | */ |
||
39 | public function get_type() { |
||
42 | |||
43 | /** |
||
44 | * Returns whether the type is an Axolotl model. |
||
45 | * |
||
46 | * @return bool |
||
47 | */ |
||
48 | public function is_model() { |
||
56 | |||
57 | /** |
||
58 | * Create a new model from the given data. |
||
59 | * |
||
60 | * @param array $data Data for the model. |
||
61 | * |
||
62 | * @return Model |
||
63 | */ |
||
64 | public function create_model( array $data ) { |
||
67 | |||
68 | /** |
||
69 | * Validates an array of element. |
||
70 | * |
||
71 | * @param array $elements Elements to be validated. |
||
72 | * |
||
73 | * @throws InvalidArgumentException |
||
74 | */ |
||
75 | public function validate_elements( array $elements ) { |
||
80 | |||
81 | /** |
||
82 | * Validate whether the |
||
83 | * |
||
84 | * @param mixed $element Element to validate. |
||
85 | * |
||
86 | * @throws InvalidArgumentException |
||
87 | */ |
||
88 | public function validate_element( $element ) { |
||
109 | |||
110 | /** |
||
111 | * Determine the type to validate against. |
||
112 | * |
||
113 | * @param string $type Type to determine. |
||
114 | * @param bool $key_type Whether the type is for keys. |
||
115 | * |
||
116 | * @return string |
||
117 | * |
||
118 | * @throws InvalidArgumentException |
||
119 | */ |
||
120 | private function determine( $type, $key_type = false ) { |
||
135 | |||
136 | /** |
||
137 | * Determines whether the given type exists. |
||
138 | * |
||
139 | * @param string $type Type to check. |
||
140 | * |
||
141 | * @return bool |
||
142 | */ |
||
143 | private function non_scalar_type_exists( $type ) { |
||
148 | |||
149 | /** |
||
150 | * Returns the type if it's scalar, otherwise, returns null. |
||
151 | * |
||
152 | * @param string $type Type to check. |
||
153 | * |
||
154 | * @return string|null |
||
155 | */ |
||
156 | private function determine_scalar( $type ) { |
||
171 | } |
||
172 |