1 | <?php |
||
15 | abstract class UniqueKeyExtractorAbstract extends DbExtractorAbstract implements JoinableInterface |
||
16 | { |
||
17 | /** |
||
18 | * the unique key name |
||
19 | * |
||
20 | * @var array|string |
||
21 | */ |
||
22 | protected $compositeKey; |
||
23 | |||
24 | /** |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $uniqueKeyName; |
||
28 | |||
29 | /** |
||
30 | * @var string |
||
31 | */ |
||
32 | protected $uniqueKeyAlias; |
||
33 | |||
34 | /** |
||
35 | * @var array |
||
36 | */ |
||
37 | protected $uniqueKeyValues = []; |
||
38 | |||
39 | /** |
||
40 | * @var array |
||
41 | */ |
||
42 | protected $uniqueKeyValueBuffer = []; |
||
43 | |||
44 | /** |
||
45 | * @var callable |
||
46 | */ |
||
47 | protected $merger; |
||
48 | |||
49 | /** |
||
50 | * @var OnClauseInterface |
||
51 | */ |
||
52 | protected $onClose; |
||
53 | |||
54 | /** |
||
55 | * @var array of OnClauseInterface |
||
56 | */ |
||
57 | protected $joinerOnCloses = []; |
||
58 | |||
59 | /** |
||
60 | * the record map |
||
61 | * |
||
62 | * @var array |
||
63 | */ |
||
64 | protected $recordMap; |
||
65 | |||
66 | /** |
||
67 | * The Joinable we may be joining against |
||
68 | * |
||
69 | * @var JoinableInterface |
||
70 | */ |
||
71 | protected $joinFrom; |
||
72 | |||
73 | /** |
||
74 | * generic extraction from tables with unique (composite) key |
||
75 | * |
||
76 | * @param string $extractQuery |
||
|
|||
77 | * @param array|string $uniqueKey can be either a unique key name as |
||
78 | * string |
||
79 | * '(table.)compositeKeyName' // ('id' by default) |
||
80 | * |
||
81 | * or an array : |
||
82 | * ['(table.)compositeKey1'] // single unique key |
||
83 | * ['(table.)compositeKey1', '(table.)compositeKey2', ] // composite unique key |
||
84 | * |
||
85 | * or an associative array in case you are using aliases : |
||
86 | * [ |
||
87 | * '(table.)compositeKey1' => 'aliasNameAsInRecord', |
||
88 | * ] |
||
89 | * |
||
90 | * and : |
||
91 | * [ |
||
92 | * '(table.)compositeKey1' => 'aliasNameAsInRecord1', |
||
93 | * '(table.)compositeKey2' => 'aliasNameAsInRecord2', |
||
94 | * // ... |
||
95 | * ] |
||
96 | */ |
||
97 | public function __construct($extractQuery = null, $uniqueKey = 'id') |
||
103 | |||
104 | /** |
||
105 | * get Joiner's ON clause. Only used in Join mode |
||
106 | * |
||
107 | * @return OnClauseInterface |
||
108 | */ |
||
109 | public function getOnClause() |
||
113 | |||
114 | /** |
||
115 | * Set Joiner's ON clause. Only used in Join mode |
||
116 | * |
||
117 | * @param OnClauseInterface $onClause |
||
118 | * |
||
119 | * @return $this |
||
120 | */ |
||
121 | public function setOnClause(OnClauseInterface $onClause) |
||
127 | |||
128 | /** |
||
129 | * register ON clause field mapping. Used by an eventual joiner to this |
||
130 | * |
||
131 | * @param OnClauseInterface $onClause |
||
132 | * |
||
133 | * @return $this |
||
134 | */ |
||
135 | public function registerJoinerOnClause(OnClauseInterface $onClause) |
||
141 | |||
142 | /** |
||
143 | * @param JoinableInterface $joinFrom |
||
144 | * |
||
145 | * @throws \Exception |
||
146 | * |
||
147 | * @return $this |
||
148 | */ |
||
149 | public function setJoinFrom(JoinableInterface $joinFrom) |
||
169 | |||
170 | /** |
||
171 | * @param string $fromKeyAlias The from unique key to get the map against |
||
172 | * as exposed in the record |
||
173 | * |
||
174 | * @return array [keyValue1, keyValue2, ...] |
||
175 | */ |
||
176 | public function getRecordMap($fromKeyAlias = null) |
||
180 | |||
181 | /** |
||
182 | * @param mixed $param |
||
183 | * |
||
184 | * @return bool |
||
185 | */ |
||
186 | public function extract($param = null) |
||
223 | |||
224 | /** |
||
225 | * @return $this |
||
226 | */ |
||
227 | public function enforceBatchSize() |
||
247 | |||
248 | /** |
||
249 | * @param mixed $record |
||
250 | * |
||
251 | * @return mixed The result of the join |
||
252 | */ |
||
253 | public function exec($record) |
||
281 | |||
282 | /** |
||
283 | * @param array|string $uniqueKey can be either a unique key name as |
||
284 | * string |
||
285 | * '(table.)compositeKeyName' // ('id' by default) |
||
286 | * |
||
287 | * or an array : |
||
288 | * ['(table.)compositeKey1'] // single unique key |
||
289 | * ['(table.)compositeKey1', '(table.)compositeKey2', ] // composite unique key |
||
290 | * |
||
291 | * or an associative array in case you are using aliases : |
||
292 | * [ |
||
293 | * '(table.)compositeKey1' => 'aliasNameAsInRecord', |
||
294 | * ] |
||
295 | * |
||
296 | * and : |
||
297 | * [ |
||
298 | * '(table.)compositeKey1' => 'aliasNameAsInRecord1', |
||
299 | * '(table.)compositeKey2' => 'aliasNameAsInRecord2', |
||
300 | * // ... |
||
301 | * ] |
||
302 | * |
||
303 | * @return $this |
||
304 | */ |
||
305 | protected function configureUniqueKey($uniqueKey) |
||
331 | |||
332 | /** |
||
333 | * @param string $keyName |
||
334 | * |
||
335 | * @return string |
||
336 | */ |
||
337 | protected function cleanUpKeyName($keyName) |
||
341 | |||
342 | /** |
||
343 | * prepare record set to obey join mode eg return record = true |
||
344 | * to break branch execution when no match are found in join more |
||
345 | * or default to be later merged in left join mode |
||
346 | * |
||
347 | * @return $this |
||
348 | */ |
||
349 | protected function setDefaultExtracted() |
||
359 | |||
360 | /** |
||
361 | * @return $this |
||
362 | */ |
||
363 | protected function genRecordMap() |
||
396 | } |
||
397 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.