@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | { |
39 | 39 | $persistence = new StorageMetadata(); |
40 | 40 | |
41 | - if (isset($mapping['db'])) { |
|
42 | - $persistence->db = $mapping['db']; |
|
41 | + if (isset($mapping[ 'db' ])) { |
|
42 | + $persistence->db = $mapping[ 'db' ]; |
|
43 | 43 | } |
44 | 44 | |
45 | - if (isset($mapping['collection'])) { |
|
46 | - $persistence->collection = $mapping['collection']; |
|
45 | + if (isset($mapping[ 'collection' ])) { |
|
46 | + $persistence->collection = $mapping[ 'collection' ]; |
|
47 | 47 | } |
48 | 48 | return $persistence; |
49 | 49 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | private function validateIdStrategy(EntityMetadata $metadata) |
114 | 114 | { |
115 | 115 | $persistence = $metadata->persistence; |
116 | - $validIdStrategies = ['object']; |
|
116 | + $validIdStrategies = [ 'object' ]; |
|
117 | 117 | if (!in_array($persistence->idStrategy, $validIdStrategies)) { |
118 | 118 | throw MetadataException::invalidMetadata($metadata->type, sprintf('The persistence id strategy "%s" is invalid. Valid types are "%s"', $persistence->idStrategy, implode('", "', $validIdStrategies))); |
119 | 119 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @param int $limit The number of Models to limit. |
84 | 84 | * @return \Doctrine\MongoDB\Cursor |
85 | 85 | */ |
86 | - public function executeFind(EntityMetadata $metadata, Store $store, array $criteria, array $fields = [], array $sort = [], $offset = 0, $limit = 0) |
|
86 | + public function executeFind(EntityMetadata $metadata, Store $store, array $criteria, array $fields = [ ], array $sort = [ ], $offset = 0, $limit = 0) |
|
87 | 87 | { |
88 | 88 | $criteria = $this->getFormatter()->formatQuery($metadata, $store, $criteria); |
89 | 89 | |
@@ -161,14 +161,14 @@ discard block |
||
161 | 161 | ]; |
162 | 162 | if (true === $owner->isChildEntity()) { |
163 | 163 | // The owner is owned by a polymorphic model. Must include the type with the inverse field criteria. |
164 | - $criteria[$inverseField] = [ |
|
165 | - Persister::IDENTIFIER_KEY => $criteria[$inverseField], |
|
164 | + $criteria[ $inverseField ] = [ |
|
165 | + Persister::IDENTIFIER_KEY => $criteria[ $inverseField ], |
|
166 | 166 | Persister::POLYMORPHIC_KEY => $owner->type, |
167 | 167 | ]; |
168 | 168 | } |
169 | 169 | if (true === $related->isChildEntity()) { |
170 | 170 | // The relationship is owned by a polymorphic model. Must include the type in the root criteria. |
171 | - $criteria[Persister::POLYMORPHIC_KEY] = $related->type; |
|
171 | + $criteria[ Persister::POLYMORPHIC_KEY ] = $related->type; |
|
172 | 172 | } |
173 | 173 | return $criteria; |
174 | 174 | } |
@@ -196,16 +196,16 @@ discard block |
||
196 | 196 | */ |
197 | 197 | public function getRetrieveCritiera(EntityMetadata $metadata, $identifiers = null) |
198 | 198 | { |
199 | - $criteria = []; |
|
199 | + $criteria = [ ]; |
|
200 | 200 | if (true === $metadata->isChildEntity()) { |
201 | - $criteria[Persister::POLYMORPHIC_KEY] = $metadata->type; |
|
201 | + $criteria[ Persister::POLYMORPHIC_KEY ] = $metadata->type; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | $identifiers = (array) $identifiers; |
205 | 205 | if (empty($identifiers)) { |
206 | 206 | return $criteria; |
207 | 207 | } |
208 | - $criteria[Persister::IDENTIFIER_KEY] = (1 === count($identifiers)) ? reset($identifiers) : $identifiers; |
|
208 | + $criteria[ Persister::IDENTIFIER_KEY ] = (1 === count($identifiers)) ? reset($identifiers) : $identifiers; |
|
209 | 209 | return $criteria; |
210 | 210 | } |
211 | 211 | |
@@ -282,8 +282,8 @@ discard block |
||
282 | 282 | if ($type !== $include) { |
283 | 283 | PersisterException::badRequest('Field projection mismatch. You cannot both exclude and include fields.'); |
284 | 284 | } |
285 | - $fields[$key] = $type; |
|
285 | + $fields[ $key ] = $type; |
|
286 | 286 | } |
287 | - return [$fields, $include]; |
|
287 | + return [ $fields, $include ]; |
|
288 | 288 | } |
289 | 289 | } |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function logQuery(array $query) |
48 | 48 | { |
49 | - if (isset($query['batchInsert']) && null !== $this->batchInsertThreshold && $this->batchInsertThreshold <= $query['num']) { |
|
50 | - $query['data'] = '**'.$query['num'].' item(s)**'; |
|
49 | + if (isset($query[ 'batchInsert' ]) && null !== $this->batchInsertThreshold && $this->batchInsertThreshold <= $query[ 'num' ]) { |
|
50 | + $query[ 'data' ] = '**'.$query[ 'num' ].' item(s)**'; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | array_walk_recursive($query, function(&$value, $key) { |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | return; |
57 | 57 | } |
58 | 58 | if (is_float($value) && is_infinite($value)) { |
59 | - $value = ($value < 0 ? '-' : '') . 'Infinity'; |
|
59 | + $value = ($value < 0 ? '-' : '').'Infinity'; |
|
60 | 60 | return; |
61 | 61 | } |
62 | 62 | if (is_float($value) && is_nan($value)) { |
@@ -80,19 +80,19 @@ discard block |
||
80 | 80 | private function convertRelationships(EntityMetadata $metadata, array $data) |
81 | 81 | { |
82 | 82 | foreach ($metadata->getRelationships() as $key => $relMeta) { |
83 | - if (!isset($data[$key])) { |
|
83 | + if (!isset($data[ $key ])) { |
|
84 | 84 | continue; |
85 | 85 | } |
86 | - if (true === $relMeta->isMany() && !is_array($data[$key])) { |
|
87 | - throw PersisterException::badRequest(sprintf('Relationship key "%s" is a reference many. Expected record data type of array, "%s" found on model "%s" for identifier "%s"', $key, gettype($data[$key]), $type, $identifier)); |
|
86 | + if (true === $relMeta->isMany() && !is_array($data[ $key ])) { |
|
87 | + throw PersisterException::badRequest(sprintf('Relationship key "%s" is a reference many. Expected record data type of array, "%s" found on model "%s" for identifier "%s"', $key, gettype($data[ $key ]), $type, $identifier)); |
|
88 | 88 | } |
89 | - $references = $relMeta->isOne() ? [$data[$key]] : $data[$key]; |
|
89 | + $references = $relMeta->isOne() ? [ $data[ $key ] ] : $data[ $key ]; |
|
90 | 90 | |
91 | - $extracted = []; |
|
91 | + $extracted = [ ]; |
|
92 | 92 | foreach ($references as $reference) { |
93 | - $extracted[] = $this->extractRelationship($relMeta, $reference); |
|
93 | + $extracted[ ] = $this->extractRelationship($relMeta, $reference); |
|
94 | 94 | } |
95 | - $data[$key] = $relMeta->isOne() ? reset($extracted) : $extracted; |
|
95 | + $data[ $key ] = $relMeta->isOne() ? reset($extracted) : $extracted; |
|
96 | 96 | } |
97 | 97 | return $data; |
98 | 98 | } |
@@ -107,10 +107,10 @@ discard block |
||
107 | 107 | */ |
108 | 108 | private function extractField($key, array $data) |
109 | 109 | { |
110 | - if (!isset($data[$key])) { |
|
110 | + if (!isset($data[ $key ])) { |
|
111 | 111 | throw PersisterException::badRequest(sprintf('Unable to extract a field value. The "%s" key was not found.', $key)); |
112 | 112 | } |
113 | - return $data[$key]; |
|
113 | + return $data[ $key ]; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -125,14 +125,14 @@ discard block |
||
125 | 125 | private function extractIdAndType(EntityMetadata $metadata, array &$data) |
126 | 126 | { |
127 | 127 | $identifier = $this->extractField(Persister::IDENTIFIER_KEY, $data); |
128 | - unset($data[Persister::IDENTIFIER_KEY]); |
|
128 | + unset($data[ Persister::IDENTIFIER_KEY ]); |
|
129 | 129 | |
130 | 130 | $key = Persister::POLYMORPHIC_KEY; |
131 | 131 | $type = $this->extractType($metadata, $data); |
132 | - if (isset($data[$key])) { |
|
133 | - unset($data[$key]); |
|
132 | + if (isset($data[ $key ])) { |
|
133 | + unset($data[ $key ]); |
|
134 | 134 | } |
135 | - return [$identifier, $type]; |
|
135 | + return [ $identifier, $type ]; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -149,9 +149,9 @@ discard block |
||
149 | 149 | $idKey = Persister::IDENTIFIER_KEY; |
150 | 150 | $typeKey = Persister::POLYMORPHIC_KEY; |
151 | 151 | |
152 | - if (true === $simple && is_array($reference) && isset($reference[$idKey])) { |
|
152 | + if (true === $simple && is_array($reference) && isset($reference[ $idKey ])) { |
|
153 | 153 | return [ |
154 | - 'id' => $reference[$idKey], |
|
154 | + 'id' => $reference[ $idKey ], |
|
155 | 155 | 'type' => $relMeta->getEntityType(), |
156 | 156 | ]; |
157 | 157 | } |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | ]; |
164 | 164 | } |
165 | 165 | |
166 | - if (false === $simple && is_array($reference) && isset($reference[$idKey]) && isset($reference[$typeKey])) { |
|
166 | + if (false === $simple && is_array($reference) && isset($reference[ $idKey ]) && isset($reference[ $typeKey ])) { |
|
167 | 167 | return [ |
168 | - 'id' => $reference[$idKey], |
|
169 | - 'type' => $reference[$typeKey], |
|
168 | + 'id' => $reference[ $idKey ], |
|
169 | + 'type' => $reference[ $typeKey ], |
|
170 | 170 | ]; |
171 | 171 | } |
172 | 172 | throw PersisterException::badRequest('Unable to extract a reference id.'); |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | * @var array |
28 | 28 | */ |
29 | 29 | private $changeSetMethods = [ |
30 | - 'attributes' => ['getAttribute', 'getAttributeDbValue'], |
|
31 | - 'hasOne' => ['getRelationship', 'getHasOneDbValue'], |
|
32 | - 'hasMany' => ['getRelationship', 'getHasManyDbValue'], |
|
33 | - 'embedOne' => ['getEmbed', 'getEmbedOneDbValue'], |
|
34 | - 'embedMany' => ['getEmbed', 'getEmbedManyDbValue'], |
|
30 | + 'attributes' => [ 'getAttribute', 'getAttributeDbValue' ], |
|
31 | + 'hasOne' => [ 'getRelationship', 'getHasOneDbValue' ], |
|
32 | + 'hasMany' => [ 'getRelationship', 'getHasManyDbValue' ], |
|
33 | + 'embedOne' => [ 'getEmbed', 'getEmbedOneDbValue' ], |
|
34 | + 'embedMany' => [ 'getEmbed', 'getEmbedManyDbValue' ], |
|
35 | 35 | ]; |
36 | 36 | |
37 | 37 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | /** |
71 | 71 | * {@inheritDoc} |
72 | 72 | */ |
73 | - public function all(EntityMetadata $metadata, Store $store, array $identifiers = [], array $fields = [], array $sort = [], $offset = 0, $limit = 0) |
|
73 | + public function all(EntityMetadata $metadata, Store $store, array $identifiers = [ ], array $fields = [ ], array $sort = [ ], $offset = 0, $limit = 0) |
|
74 | 74 | { |
75 | 75 | $criteria = $this->getQuery()->getRetrieveCritiera($metadata, $identifiers); |
76 | 76 | $cursor = $this->getQuery()->executeFind($metadata, $store, $criteria, $fields, $sort, $offset, $limit); |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | /** |
197 | 197 | * {@inheritDoc} |
198 | 198 | */ |
199 | - public function query(EntityMetadata $metadata, Store $store, array $criteria, array $fields = [], array $sort = [], $offset = 0, $limit = 0) |
|
199 | + public function query(EntityMetadata $metadata, Store $store, array $criteria, array $fields = [ ], array $sort = [ ], $offset = 0, $limit = 0) |
|
200 | 200 | { |
201 | 201 | $cursor = $this->getQuery()->executeFind($metadata, $store, $criteria, $fields, $sort, $offset, $limit); |
202 | 202 | return $this->getHydrator()->createCursorRecordSet($metadata, $cursor, $store); |
@@ -246,8 +246,8 @@ discard block |
||
246 | 246 | |
247 | 247 | foreach ($this->changeSetMethods as $setKey => $methods) { |
248 | 248 | list($metaMethod, $formatMethod) = $methods; |
249 | - foreach ($changeset[$setKey] as $key => $values) { |
|
250 | - $value = $formatter->$formatMethod($metadata->$metaMethod($key), $values['new']); |
|
249 | + foreach ($changeset[ $setKey ] as $key => $values) { |
|
250 | + $value = $formatter->$formatMethod($metadata->$metaMethod($key), $values[ 'new' ]); |
|
251 | 251 | $obj = $handler($key, $value, $obj); |
252 | 252 | } |
253 | 253 | } |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | $this->getIdentifierKey() => $this->convertId($model->getId()), |
268 | 268 | ]; |
269 | 269 | if (true === $metadata->isChildEntity()) { |
270 | - $insert[$this->getPolymorphicKey()] = $metadata->type; |
|
270 | + $insert[ $this->getPolymorphicKey() ] = $metadata->type; |
|
271 | 271 | } |
272 | 272 | return $this->appendChangeSet($model, $insert, $this->getCreateChangeSetHandler()); |
273 | 273 | } |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | */ |
281 | 281 | private function createUpdateObj(Model $model) |
282 | 282 | { |
283 | - return $this->appendChangeSet($model, [], $this->getUpdateChangeSetHandler()); |
|
283 | + return $this->appendChangeSet($model, [ ], $this->getUpdateChangeSetHandler()); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -290,9 +290,9 @@ discard block |
||
290 | 290 | */ |
291 | 291 | private function getCreateChangeSetHandler() |
292 | 292 | { |
293 | - return function ($key, $value, $obj) { |
|
293 | + return function($key, $value, $obj) { |
|
294 | 294 | if (null !== $value) { |
295 | - $obj[$key] = $value; |
|
295 | + $obj[ $key ] = $value; |
|
296 | 296 | } |
297 | 297 | return $obj; |
298 | 298 | }; |
@@ -305,13 +305,13 @@ discard block |
||
305 | 305 | */ |
306 | 306 | private function getUpdateChangeSetHandler() |
307 | 307 | { |
308 | - return function ($key, $value, $obj) { |
|
308 | + return function($key, $value, $obj) { |
|
309 | 309 | $op = '$set'; |
310 | 310 | if (null === $value) { |
311 | 311 | $op = '$unset'; |
312 | 312 | $value = 1; |
313 | 313 | } |
314 | - $obj[$op][$key] = $value; |
|
314 | + $obj[ $op ][ $key ] = $value; |
|
315 | 315 | return $obj; |
316 | 316 | }; |
317 | 317 | } |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | * @var array |
31 | 31 | */ |
32 | 32 | private $ops = [ |
33 | - 'root' => ['$and', '$or', '$nor'], |
|
34 | - 'single' => ['$eq', '$gt', '$gte', '$lt', '$lte', '$ne'], |
|
35 | - 'multiple' => ['$in', '$nin', '$all'], |
|
36 | - 'recursive' => ['$not', '$elemMatch'], |
|
37 | - 'ignore' => ['$exists', '$type', '$mod', '$size', '$regex', '$text', '$where'], |
|
33 | + 'root' => [ '$and', '$or', '$nor' ], |
|
34 | + 'single' => [ '$eq', '$gt', '$gte', '$lt', '$lte', '$ne' ], |
|
35 | + 'multiple' => [ '$in', '$nin', '$all' ], |
|
36 | + 'recursive' => [ '$not', '$elemMatch' ], |
|
37 | + 'ignore' => [ '$exists', '$type', '$mod', '$size', '$regex', '$text', '$where' ], |
|
38 | 38 | ]; |
39 | 39 | |
40 | 40 | /** |
@@ -49,23 +49,23 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function formatQuery(EntityMetadata $metadata, Store $store, array $criteria) |
51 | 51 | { |
52 | - $formatted = []; |
|
52 | + $formatted = [ ]; |
|
53 | 53 | foreach ($criteria as $key => $value) { |
54 | 54 | |
55 | 55 | if ($this->isOpType('root', $key) && is_array($value)) { |
56 | 56 | foreach ($value as $subKey => $subValue) { |
57 | - $formatted[$key][$subKey] = $this->formatQuery($metadata, $store, $subValue); |
|
57 | + $formatted[ $key ][ $subKey ] = $this->formatQuery($metadata, $store, $subValue); |
|
58 | 58 | } |
59 | 59 | continue; |
60 | 60 | } |
61 | 61 | |
62 | 62 | if ($this->isOperator($key) && is_array($value)) { |
63 | - $formatted[$key] = $this->formatQuery($metadata, $store, $value); |
|
63 | + $formatted[ $key ] = $this->formatQuery($metadata, $store, $value); |
|
64 | 64 | continue; |
65 | 65 | } |
66 | 66 | |
67 | 67 | list($key, $value) = $this->formatQueryElement($key, $value, $metadata, $store); |
68 | - $formatted[$key] = $value; |
|
68 | + $formatted[ $key ] = $value; |
|
69 | 69 | } |
70 | 70 | return $formatted; |
71 | 71 | } |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | if (null === $embeds) { |
106 | 106 | return; |
107 | 107 | } |
108 | - $created = []; |
|
108 | + $created = [ ]; |
|
109 | 109 | foreach ($embeds as $embed) { |
110 | - $created[] = $this->createEmbed($embeddedPropMeta, $embed); |
|
110 | + $created[ ] = $this->createEmbed($embeddedPropMeta, $embed); |
|
111 | 111 | } |
112 | 112 | return empty($created) ? null : $created; |
113 | 113 | } |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | if (null === $models || true === $relMeta->isInverse) { |
155 | 155 | return null; |
156 | 156 | } |
157 | - $references = []; |
|
157 | + $references = [ ]; |
|
158 | 158 | foreach ($models as $model) { |
159 | - $references[] = $this->createReference($relMeta, $model); |
|
159 | + $references[ ] = $this->createReference($relMeta, $model); |
|
160 | 160 | } |
161 | 161 | return empty($references) ? null : $references; |
162 | 162 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | */ |
183 | 183 | public function getIdentifierFields() |
184 | 184 | { |
185 | - return [Persister::IDENTIFIER_KEY, EntityMetadata::ID_KEY]; |
|
185 | + return [ Persister::IDENTIFIER_KEY, EntityMetadata::ID_KEY ]; |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | */ |
193 | 193 | public function getTypeFields() |
194 | 194 | { |
195 | - return [Persister::POLYMORPHIC_KEY, EntityMetadata::TYPE_KEY]; |
|
195 | + return [ Persister::POLYMORPHIC_KEY, EntityMetadata::TYPE_KEY ]; |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -241,20 +241,20 @@ discard block |
||
241 | 241 | { |
242 | 242 | $embedMeta = $embeddedPropMeta->embedMeta; |
243 | 243 | |
244 | - $obj = []; |
|
244 | + $obj = [ ]; |
|
245 | 245 | foreach ($embedMeta->getAttributes() as $key => $attrMeta) { |
246 | 246 | $value = $this->getAttributeDbValue($attrMeta, $embed->get($key)); |
247 | 247 | if (null === $value) { |
248 | 248 | continue; |
249 | 249 | } |
250 | - $obj[$key] = $value; |
|
250 | + $obj[ $key ] = $value; |
|
251 | 251 | } |
252 | 252 | foreach ($embedMeta->getEmbeds() as $key => $propMeta) { |
253 | 253 | $value = (true === $propMeta->isOne()) ? $this->getEmbedOneDbValue($propMeta, $embed->get($key)) : $this->getEmbedManyDbValue($propMeta, $embed->get($key)); |
254 | 254 | if (null === $value) { |
255 | 255 | continue; |
256 | 256 | } |
257 | - $obj[$key] = $value; |
|
257 | + $obj[ $key ] = $value; |
|
258 | 258 | } |
259 | 259 | return $obj; |
260 | 260 | } |
@@ -268,11 +268,11 @@ discard block |
||
268 | 268 | */ |
269 | 269 | private function createReference(RelationshipMetadata $relMeta, Model $model) |
270 | 270 | { |
271 | - $reference = []; |
|
271 | + $reference = [ ]; |
|
272 | 272 | $identifier = $this->getIdentifierDbValue($model->getId()); |
273 | 273 | if (true === $relMeta->isPolymorphic()) { |
274 | - $reference[Persister::IDENTIFIER_KEY] = $identifier; |
|
275 | - $reference[Persister::TYPE_KEY] = $model->getType(); |
|
274 | + $reference[ Persister::IDENTIFIER_KEY ] = $identifier; |
|
275 | + $reference[ Persister::TYPE_KEY ] = $model->getType(); |
|
276 | 276 | return $reference; |
277 | 277 | } |
278 | 278 | return $identifier; |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | } |
312 | 312 | |
313 | 313 | // Pass remaining elements unconverted. |
314 | - return [$key, $value]; |
|
314 | + return [ $key, $value ]; |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -335,15 +335,15 @@ discard block |
||
335 | 335 | if (is_array($value)) { |
336 | 336 | |
337 | 337 | if (true === $this->hasOperators($value)) { |
338 | - return [$key, $this->formatQueryExpression($value, $converter)]; |
|
338 | + return [ $key, $this->formatQueryExpression($value, $converter) ]; |
|
339 | 339 | } |
340 | 340 | |
341 | - if (in_array($attrMeta->dataType, ['array', 'object'])) { |
|
342 | - return [$key, $value]; |
|
341 | + if (in_array($attrMeta->dataType, [ 'array', 'object' ])) { |
|
342 | + return [ $key, $value ]; |
|
343 | 343 | } |
344 | - return [$key, $this->formatQueryExpression(['$in' => $value], $converter)]; |
|
344 | + return [ $key, $this->formatQueryExpression([ '$in' => $value ], $converter) ]; |
|
345 | 345 | } |
346 | - return [$key, $converter($value)]; |
|
346 | + return [ $key, $converter($value) ]; |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | /** |
@@ -366,30 +366,30 @@ discard block |
||
366 | 366 | $root = array_shift($parts); |
367 | 367 | if (false === $metadata->hasRelationship($root)) { |
368 | 368 | // Nothing to format. Allow the dotted field to pass normally. |
369 | - return [$key, $value]; |
|
369 | + return [ $key, $value ]; |
|
370 | 370 | } |
371 | - $hasIndex = is_numeric($parts[0]); |
|
371 | + $hasIndex = is_numeric($parts[ 0 ]); |
|
372 | 372 | |
373 | 373 | if (true === $hasIndex) { |
374 | - $subKey = isset($parts[1]) ? $parts[1] : 'id'; |
|
374 | + $subKey = isset($parts[ 1 ]) ? $parts[ 1 ] : 'id'; |
|
375 | 375 | } else { |
376 | - $subKey = $parts[0]; |
|
376 | + $subKey = $parts[ 0 ]; |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | if ($this->isIdentifierField($subKey)) { |
380 | 380 | // Handle like a regular relationship |
381 | 381 | list($key, $value) = $this->formatQueryElementRel($root, $value, $metadata, $store); |
382 | - $key = (true === $hasIndex) ? sprintf('%s.%s', $key, $parts[0]) : $key; |
|
383 | - return [$key, $value]; |
|
382 | + $key = (true === $hasIndex) ? sprintf('%s.%s', $key, $parts[ 0 ]) : $key; |
|
383 | + return [ $key, $value ]; |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | if ($this->isTypeField($subKey)) { |
387 | 387 | // Handle as a model type field. |
388 | 388 | list($key, $value) = $this->formatQueryElementRoot($subKey, $value, $metadata); |
389 | - $key = (true === $hasIndex) ? sprintf('%s.%s.%s', $root, $parts[0], $key) : sprintf('%s.%s', $root, $key); |
|
390 | - return [$key, $value]; |
|
389 | + $key = (true === $hasIndex) ? sprintf('%s.%s.%s', $root, $parts[ 0 ], $key) : sprintf('%s.%s', $root, $key); |
|
390 | + return [ $key, $value ]; |
|
391 | 391 | } |
392 | - return [$key, $value]; |
|
392 | + return [ $key, $value ]; |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | /** |
@@ -415,10 +415,10 @@ discard block |
||
415 | 415 | } |
416 | 416 | |
417 | 417 | if (is_array($value)) { |
418 | - $value = (true === $this->hasOperators($value)) ? $value : ['$in' => $value]; |
|
419 | - return [$key, $this->formatQueryExpression($value, $converter)]; |
|
418 | + $value = (true === $this->hasOperators($value)) ? $value : [ '$in' => $value ]; |
|
419 | + return [ $key, $this->formatQueryExpression($value, $converter) ]; |
|
420 | 420 | } |
421 | - return [$key, $converter($value)]; |
|
421 | + return [ $key, $converter($value) ]; |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | |
@@ -443,10 +443,10 @@ discard block |
||
443 | 443 | |
444 | 444 | $converter = $this->getQueryRootConverter($metadata, $dbKey); |
445 | 445 | if (is_array($value)) { |
446 | - $value = (true === $this->hasOperators($value)) ? $value : ['$in' => $value]; |
|
447 | - return [$dbKey, $this->formatQueryExpression($value, $converter)]; |
|
446 | + $value = (true === $this->hasOperators($value)) ? $value : [ '$in' => $value ]; |
|
447 | + return [ $dbKey, $this->formatQueryExpression($value, $converter) ]; |
|
448 | 448 | } |
449 | - return [$dbKey, $converter($value)]; |
|
449 | + return [ $dbKey, $converter($value) ]; |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | /** |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | foreach ($expression as $key => $value) { |
462 | 462 | |
463 | 463 | if ('$regex' === $key && !$value instanceof \MongoRegex) { |
464 | - $expression[$key] = new \MongoRegex($value); |
|
464 | + $expression[ $key ] = new \MongoRegex($value); |
|
465 | 465 | continue; |
466 | 466 | } |
467 | 467 | |
@@ -470,25 +470,25 @@ discard block |
||
470 | 470 | } |
471 | 471 | |
472 | 472 | if (true === $this->isOpType('single', $key)) { |
473 | - $expression[$key] = $converter($value); |
|
473 | + $expression[ $key ] = $converter($value); |
|
474 | 474 | continue; |
475 | 475 | } |
476 | 476 | |
477 | 477 | if (true === $this->isOpType('multiple', $key)) { |
478 | 478 | $value = (array) $value; |
479 | 479 | foreach ($value as $subKey => $subValue) { |
480 | - $expression[$key][$subKey] = $converter($subValue); |
|
480 | + $expression[ $key ][ $subKey ] = $converter($subValue); |
|
481 | 481 | } |
482 | 482 | continue; |
483 | 483 | } |
484 | 484 | |
485 | 485 | if (true === $this->isOpType('recursive', $key)) { |
486 | 486 | $value = (array) $value; |
487 | - $expression[$key] = $this->formatQueryExpression($value, $converter); |
|
487 | + $expression[ $key ] = $this->formatQueryExpression($value, $converter); |
|
488 | 488 | continue; |
489 | 489 | } |
490 | 490 | |
491 | - $expression[$key] = $converter($value); |
|
491 | + $expression[ $key ] = $converter($value); |
|
492 | 492 | } |
493 | 493 | return $expression; |
494 | 494 | } |
@@ -502,8 +502,8 @@ discard block |
||
502 | 502 | */ |
503 | 503 | private function getQueryAttrConverter(Store $store, AttributeMetadata $attrMeta) |
504 | 504 | { |
505 | - return function ($value) use ($store, $attrMeta) { |
|
506 | - if (in_array($attrMeta->dataType, ['object', 'array'])) { |
|
505 | + return function($value) use ($store, $attrMeta) { |
|
506 | + if (in_array($attrMeta->dataType, [ 'object', 'array' ])) { |
|
507 | 507 | // Leave the value as is. |
508 | 508 | return $value; |
509 | 509 | } |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | */ |
578 | 578 | private function isOperator($key) |
579 | 579 | { |
580 | - return isset($key[0]) && '$' === $key[0]; |
|
580 | + return isset($key[ 0 ]) && '$' === $key[ 0 ]; |
|
581 | 581 | } |
582 | 582 | |
583 | 583 | /** |
@@ -589,9 +589,9 @@ discard block |
||
589 | 589 | */ |
590 | 590 | private function isOpType($type, $key) |
591 | 591 | { |
592 | - if (!isset($this->ops[$type])) { |
|
592 | + if (!isset($this->ops[ $type ])) { |
|
593 | 593 | return false; |
594 | 594 | } |
595 | - return in_array($key, $this->ops[$type]); |
|
595 | + return in_array($key, $this->ops[ $type ]); |
|
596 | 596 | } |
597 | 597 | } |