1 | <?php |
||
13 | abstract class MetaProvider |
||
14 | { |
||
15 | /** |
||
16 | * This pattern is used to see whether a missing |
||
17 | * method is a "total" method or not. |
||
18 | * |
||
19 | * @var string |
||
20 | */ |
||
21 | protected static $totalMethod = '/^getTotal([\w]+)$/'; |
||
22 | |||
23 | /** |
||
24 | * This pattern is used to add message retrieval for a given |
||
25 | * type - i.e getFailures() or getErrors(). |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | protected static $messageMethod = '/^get((Failure|Error)s)$/'; |
||
30 | |||
31 | /** |
||
32 | * Simplify aggregation of totals or messages. |
||
33 | * |
||
34 | * @param mixed $method |
||
35 | * @param mixed $args |
||
36 | */ |
||
37 | 22 | public function __call(string $method, array $args) |
|
46 | |||
47 | /** |
||
48 | * Return a value as a float or integer. |
||
49 | * |
||
50 | * @param $property |
||
51 | * |
||
52 | * @return float|int |
||
53 | */ |
||
54 | 14 | protected function getNumericValue(string $property) |
|
60 | |||
61 | /** |
||
62 | * Return messages for a given type. |
||
63 | * |
||
64 | * @param $type |
||
65 | * |
||
66 | * @return array |
||
67 | */ |
||
68 | 10 | protected function getMessages(string $type): array |
|
84 | } |
||
85 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: