1 | <?php |
||
25 | class BelongsTo extends AbstractRelation implements RelationInterface |
||
26 | { |
||
27 | /** |
||
28 | * Relations utility methods |
||
29 | */ |
||
30 | use RelationsUtilityMethods; |
||
31 | |||
32 | /** |
||
33 | * BelongsTo relation |
||
34 | * |
||
35 | * @param array|object $options The parameters from annotation |
||
36 | */ |
||
37 | 6 | public function __construct($options) |
|
49 | |||
50 | /** |
||
51 | * Handles the before select callback |
||
52 | * |
||
53 | * @param Select $event |
||
54 | */ |
||
55 | 3 | public function beforeSelect(Select $event) |
|
68 | |||
69 | /** |
||
70 | * Handles the after select callback |
||
71 | * |
||
72 | * @param Select $event |
||
73 | */ |
||
74 | public function afterSelect(Select $event) |
||
81 | |||
82 | /** |
||
83 | * Registers the listener for before select event |
||
84 | */ |
||
85 | 6 | private function registerListeners() |
|
99 | |||
100 | /** |
||
101 | * Prefixed fields for join |
||
102 | * |
||
103 | * @return array |
||
104 | */ |
||
105 | 2 | private function getFieldsPrefixed() |
|
116 | |||
117 | /** |
||
118 | * Check if entity is already loaded and uses it. |
||
119 | * |
||
120 | * If not loaded the entity will be created and loaded to the repository's |
||
121 | * identity map so that it can be reused next time. |
||
122 | * |
||
123 | * @param array $dataRow |
||
124 | * |
||
125 | * @return null|EntityCollection|EntityInterface|EntityInterface[] |
||
126 | */ |
||
127 | private function getFromMap($dataRow) |
||
137 | |||
138 | /** |
||
139 | * Creates and maps related entity |
||
140 | * |
||
141 | * @param array $dataRow |
||
142 | * |
||
143 | * @return null|EntityCollection|EntityInterface|EntityInterface[] |
||
144 | */ |
||
145 | private function map($dataRow) |
||
154 | |||
155 | /** |
||
156 | * Gets a data array with fields and values for parent entity creation |
||
157 | * |
||
158 | * @param array $dataRow |
||
159 | * |
||
160 | * @return array |
||
161 | */ |
||
162 | private function getData($dataRow) |
||
174 | |||
175 | /** |
||
176 | * Loads the entity or entity collection for this relation |
||
177 | * |
||
178 | * @param EntityInterface $entity |
||
179 | * |
||
180 | * @return null|EntityInterface |
||
181 | */ |
||
182 | 2 | public function load(EntityInterface $entity) |
|
209 | } |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.