1 | <?php |
||
15 | trait LocalizationSerializerTrait { |
||
16 | |||
17 | /** |
||
18 | * @param mixed $model |
||
19 | * @return Relationship |
||
20 | */ |
||
21 | public function extLang($model) { |
||
29 | |||
30 | /** |
||
31 | * @param mixed $model |
||
32 | * @param array $fields |
||
33 | */ |
||
34 | public function getAttributes($model, array $fields = null) { |
||
47 | |||
48 | /** |
||
49 | */ |
||
50 | public function getFields() { |
||
53 | |||
54 | /** |
||
55 | * @param mixed $model |
||
56 | * @return string |
||
57 | */ |
||
58 | public function getId($model) { |
||
61 | |||
62 | /** |
||
63 | */ |
||
64 | public function getRelationships() { |
||
72 | |||
73 | /** |
||
74 | */ |
||
75 | public function getSortFields() { |
||
78 | |||
79 | /** |
||
80 | * @param mixed $model |
||
81 | * @return string |
||
82 | */ |
||
83 | public function getType($model) { |
||
86 | |||
87 | /** |
||
88 | * @param mixed $model |
||
89 | * @param mixed $data |
||
90 | * @return mixed The model |
||
91 | */ |
||
92 | public function hydrate($model, $data) { |
||
103 | |||
104 | /** |
||
105 | * @param mixed $model |
||
106 | * @return Relationship |
||
107 | */ |
||
108 | public function languageVariants($model) { |
||
112 | |||
113 | /** |
||
114 | * @param mixed $model |
||
115 | * @return Relationship |
||
116 | */ |
||
117 | public function parent($model) { |
||
125 | |||
126 | /** |
||
127 | * @param mixed $model |
||
128 | * @return Relationship |
||
129 | */ |
||
130 | public function script($model) { |
||
138 | |||
139 | /** |
||
140 | * @param mixed $model |
||
141 | * @param mixed $data |
||
142 | */ |
||
143 | abstract protected function hydrateRelationships($model, $data); |
||
144 | } |
||
145 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.