1 | <?php |
||
21 | abstract class Serializer |
||
22 | { |
||
23 | /** |
||
24 | * Fully qualified model class name. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | protected static $class; |
||
29 | |||
30 | /** |
||
31 | * Serializes the given data in a correct domain model class. |
||
32 | * |
||
33 | * @param mixed $data The given data |
||
34 | * |
||
35 | * @throws \Exception when the given data is incorrect |
||
36 | * |
||
37 | * @return array|Model |
||
38 | */ |
||
39 | public static function serialize($data) |
||
56 | |||
57 | /** |
||
58 | * Gets the fully qualified class name. |
||
59 | * |
||
60 | * @throws \Exception when the class is not a model instance |
||
61 | * |
||
62 | * @return string |
||
63 | */ |
||
64 | private static function className() |
||
73 | } |
||
74 |
Let’s assume you have a class which uses late-static binding:
}
The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the
getSomeVariable()
on that sub-class, you will receive a runtime error:In the case above, it makes sense to update
SomeClass
to useself
instead: