1 | <?php |
||
19 | abstract class Attribute extends Collection |
||
20 | { |
||
21 | /** |
||
22 | * Attributes alias. |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $aliases = []; |
||
27 | |||
28 | /** |
||
29 | * Required attributes. |
||
30 | * |
||
31 | * @var array |
||
32 | */ |
||
33 | protected $requireds = []; |
||
34 | |||
35 | /** |
||
36 | * Constructor. |
||
37 | * |
||
38 | * @param array $attributes |
||
39 | */ |
||
40 | public function __construct($attributes = []) |
||
44 | |||
45 | /** |
||
46 | * Set attribute. |
||
47 | * |
||
48 | * @param string $attribute |
||
49 | * @param string $value |
||
50 | * |
||
51 | * @return Attribute |
||
52 | */ |
||
53 | public function setAttribute($attribute, $value) |
||
59 | |||
60 | /** |
||
61 | * Get attribute. |
||
62 | * |
||
63 | * @param string $attribute |
||
64 | * @param mixed $default |
||
65 | * |
||
66 | * @return mixed |
||
67 | */ |
||
68 | public function getAttribute($attribute, $default) |
||
72 | |||
73 | /** |
||
74 | * Set attribute. |
||
75 | * |
||
76 | * @param string $attribute |
||
77 | * @param mixed $value |
||
78 | * |
||
79 | * @return Attribute |
||
80 | */ |
||
81 | public function with($attribute, $value) |
||
91 | |||
92 | /** |
||
93 | * Attribute validation. |
||
94 | * |
||
95 | * @param string $attribute |
||
96 | * @param mixed $value |
||
97 | * |
||
98 | * @return bool |
||
99 | */ |
||
100 | protected function validate($attribute, $value) |
||
104 | |||
105 | /** |
||
106 | * Override parent set() method. |
||
107 | * |
||
108 | * @param string $attribute |
||
109 | * @param mixed $value |
||
110 | */ |
||
111 | public function set($attribute, $value = null) |
||
115 | |||
116 | /** |
||
117 | * Override parent get() method. |
||
118 | * |
||
119 | * @param string $attribute |
||
120 | * @param mixed $default |
||
121 | * |
||
122 | * @return mixed |
||
123 | */ |
||
124 | public function get($attribute, $default = null) |
||
128 | |||
129 | /** |
||
130 | * Magic call. |
||
131 | * |
||
132 | * @param string $method |
||
133 | * @param array $args |
||
134 | * |
||
135 | * @return Attribute |
||
136 | */ |
||
137 | public function __call($method, $args) |
||
145 | |||
146 | /** |
||
147 | * Magic set. |
||
148 | * |
||
149 | * @param string $property |
||
150 | * @param mixed $value |
||
151 | * |
||
152 | * @return Attribute |
||
153 | */ |
||
154 | public function __set($property, $value) |
||
158 | |||
159 | /** |
||
160 | * Whether or not an data exists by key. |
||
161 | * |
||
162 | * @param string $key |
||
163 | * |
||
164 | * @return bool |
||
165 | */ |
||
166 | public function __isset($key) |
||
170 | |||
171 | /** |
||
172 | * Return the raw name of attribute. |
||
173 | * |
||
174 | * @param string $key |
||
175 | * |
||
176 | * @return string |
||
177 | */ |
||
178 | protected function getRealKey($key) |
||
186 | |||
187 | /** |
||
188 | * Check required attributes. |
||
189 | * |
||
190 | * @throws InvalidArgumentException |
||
191 | */ |
||
192 | protected function checkRequiredAttributes() |
||
200 | |||
201 | /** |
||
202 | * Return all items. |
||
203 | * |
||
204 | * @throws InvalidArgumentException |
||
205 | * |
||
206 | * @return array |
||
207 | */ |
||
208 | public function all() |
||
214 | } |
||
215 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.