@@ -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.'); | 
                                                        
@@ -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::POLYMORPHIC_KEY] = $model->getType();  | 
                                                        |
| 274 | + $reference[ Persister::IDENTIFIER_KEY ] = $identifier;  | 
                                                        |
| 275 | + $reference[ Persister::POLYMORPHIC_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 | }  | 
                                                        
@@ -16,7 +16,6 @@ discard block  | 
                                                    ||
| 16 | 16 | * Applies schemata  | 
                                                        
| 17 | 17 | *  | 
                                                        
| 18 | 18 | * @param Collection $collection The MongoDB Collection  | 
                                                        
| 19 | - * @param array $index Associative array containing index data  | 
                                                        |
| 20 | 19 | */  | 
                                                        
| 21 | 20 | public function createSchemata(Collection $collection, array $schemata)  | 
                                                        
| 22 | 21 |      { | 
                                                        
@@ -31,7 +30,6 @@ discard block  | 
                                                    ||
| 31 | 30 | * @todo Implement  | 
                                                        
| 32 | 31 | *  | 
                                                        
| 33 | 32 | * @param Collection $collection The MongoDB Collection  | 
                                                        
| 34 | - * @param array $index Associative array containing index data  | 
                                                        |
| 35 | 33 | */  | 
                                                        
| 36 | 34 | public function syncSchemata(Collection $collection, array $schemata)  | 
                                                        
| 37 | 35 |      { | 
                                                        
@@ -21,11 +21,11 @@  | 
                                                    ||
| 21 | 21 | public function createSchemata(Collection $collection, array $schemata)  | 
                                                        
| 22 | 22 |      { | 
                                                        
| 23 | 23 |          foreach ($schemata as $schema) { | 
                                                        
| 24 | -            if (!isset($schema['keys']) || empty($schema['keys'])) { | 
                                                        |
| 24 | +            if (!isset($schema[ 'keys' ]) || empty($schema[ 'keys' ])) { | 
                                                        |
| 25 | 25 |                  throw new \InvalidArgumentException('Cannot create an index with no keys defined.'); | 
                                                        
| 26 | 26 | }  | 
                                                        
| 27 | - $schema['options']['background'] = true;  | 
                                                        |
| 28 | - $collection->ensureIndex($schema['keys'], $schema['options']);  | 
                                                        |
| 27 | + $schema[ 'options' ][ 'background' ] = true;  | 
                                                        |
| 28 | + $collection->ensureIndex($schema[ 'keys' ], $schema[ 'options' ]);  | 
                                                        |
| 29 | 29 | }  | 
                                                        
| 30 | 30 | }  | 
                                                        
| 31 | 31 | |
@@ -41,7 +41,7 @@  | 
                                                    ||
| 41 | 41 | *  | 
                                                        
| 42 | 42 | * @var array  | 
                                                        
| 43 | 43 | */  | 
                                                        
| 44 | - public $schemata = [];  | 
                                                        |
| 44 | + public $schemata = [ ];  | 
                                                        |
| 45 | 45 | |
| 46 | 46 | /**  | 
                                                        
| 47 | 47 |       * {@inheritDoc} | 
                                                        
@@ -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 | /**  | 
                                                        
@@ -76,7 +76,7 @@ discard block  | 
                                                    ||
| 76 | 76 | /**  | 
                                                        
| 77 | 77 |       * {@inheritDoc} | 
                                                        
| 78 | 78 | */  | 
                                                        
| 79 | - public function all(EntityMetadata $metadata, Store $store, array $identifiers = [], array $fields = [], array $sort = [], $offset = 0, $limit = 0)  | 
                                                        |
| 79 | + public function all(EntityMetadata $metadata, Store $store, array $identifiers = [ ], array $fields = [ ], array $sort = [ ], $offset = 0, $limit = 0)  | 
                                                        |
| 80 | 80 |      { | 
                                                        
| 81 | 81 | $criteria = $this->getQuery()->getRetrieveCritiera($metadata, $identifiers);  | 
                                                        
| 82 | 82 | $cursor = $this->getQuery()->executeFind($metadata, $store, $criteria, $fields, $sort, $offset, $limit);  | 
                                                        
@@ -109,7 +109,7 @@ discard block  | 
                                                    ||
| 109 | 109 | public function createSchemata(EntityMetadata $metadata)  | 
                                                        
| 110 | 110 |      { | 
                                                        
| 111 | 111 | $collection = $this->getQuery()->getModelCollection($metadata);  | 
                                                        
| 112 | - $schemata = $metadata->persistence->schemata ?: [];  | 
                                                        |
| 112 | + $schemata = $metadata->persistence->schemata ?: [ ];  | 
                                                        |
| 113 | 113 | return $this->schemaManager->createSchemata($collection, $schemata);  | 
                                                        
| 114 | 114 | }  | 
                                                        
| 115 | 115 | |
@@ -119,7 +119,7 @@ discard block  | 
                                                    ||
| 119 | 119 | public function syncSchemata(EntityMetadata $metadata)  | 
                                                        
| 120 | 120 |      { | 
                                                        
| 121 | 121 | $collection = $this->getQuery()->getModelCollection($metadata);  | 
                                                        
| 122 | - $schemata = $metadata->persistence->schemata ?: [];  | 
                                                        |
| 122 | + $schemata = $metadata->persistence->schemata ?: [ ];  | 
                                                        |
| 123 | 123 | return $this->schemaManager->syncSchemata($collection);  | 
                                                        
| 124 | 124 | }  | 
                                                        
| 125 | 125 | |
@@ -222,7 +222,7 @@ discard block  | 
                                                    ||
| 222 | 222 | /**  | 
                                                        
| 223 | 223 |       * {@inheritDoc} | 
                                                        
| 224 | 224 | */  | 
                                                        
| 225 | - public function query(EntityMetadata $metadata, Store $store, array $criteria, array $fields = [], array $sort = [], $offset = 0, $limit = 0)  | 
                                                        |
| 225 | + public function query(EntityMetadata $metadata, Store $store, array $criteria, array $fields = [ ], array $sort = [ ], $offset = 0, $limit = 0)  | 
                                                        |
| 226 | 226 |      { | 
                                                        
| 227 | 227 | $cursor = $this->getQuery()->executeFind($metadata, $store, $criteria, $fields, $sort, $offset, $limit);  | 
                                                        
| 228 | 228 | return $this->getHydrator()->createCursorRecordSet($metadata, $cursor, $store);  | 
                                                        
@@ -272,8 +272,8 @@ discard block  | 
                                                    ||
| 272 | 272 | |
| 273 | 273 |          foreach ($this->changeSetMethods as $setKey => $methods) { | 
                                                        
| 274 | 274 | list($metaMethod, $formatMethod) = $methods;  | 
                                                        
| 275 | -            foreach ($changeset[$setKey] as $key => $values) { | 
                                                        |
| 276 | - $value = $formatter->$formatMethod($metadata->$metaMethod($key), $values['new']);  | 
                                                        |
| 275 | +            foreach ($changeset[ $setKey ] as $key => $values) { | 
                                                        |
| 276 | + $value = $formatter->$formatMethod($metadata->$metaMethod($key), $values[ 'new' ]);  | 
                                                        |
| 277 | 277 | $obj = $handler($key, $value, $obj);  | 
                                                        
| 278 | 278 | }  | 
                                                        
| 279 | 279 | }  | 
                                                        
@@ -293,7 +293,7 @@ discard block  | 
                                                    ||
| 293 | 293 | $this->getIdentifierKey() => $this->convertId($model->getId()),  | 
                                                        
| 294 | 294 | ];  | 
                                                        
| 295 | 295 |          if (true === $metadata->isChildEntity()) { | 
                                                        
| 296 | - $insert[$this->getPolymorphicKey()] = $metadata->type;  | 
                                                        |
| 296 | + $insert[ $this->getPolymorphicKey() ] = $metadata->type;  | 
                                                        |
| 297 | 297 | }  | 
                                                        
| 298 | 298 | return $this->appendChangeSet($model, $insert, $this->getCreateChangeSetHandler());  | 
                                                        
| 299 | 299 | }  | 
                                                        
@@ -306,7 +306,7 @@ discard block  | 
                                                    ||
| 306 | 306 | */  | 
                                                        
| 307 | 307 | private function createUpdateObj(Model $model)  | 
                                                        
| 308 | 308 |      { | 
                                                        
| 309 | - return $this->appendChangeSet($model, [], $this->getUpdateChangeSetHandler());  | 
                                                        |
| 309 | + return $this->appendChangeSet($model, [ ], $this->getUpdateChangeSetHandler());  | 
                                                        |
| 310 | 310 | }  | 
                                                        
| 311 | 311 | |
| 312 | 312 | /**  | 
                                                        
@@ -316,9 +316,9 @@ discard block  | 
                                                    ||
| 316 | 316 | */  | 
                                                        
| 317 | 317 | private function getCreateChangeSetHandler()  | 
                                                        
| 318 | 318 |      { | 
                                                        
| 319 | -        return function ($key, $value, $obj) { | 
                                                        |
| 319 | +        return function($key, $value, $obj) { | 
                                                        |
| 320 | 320 |              if (null !== $value) { | 
                                                        
| 321 | - $obj[$key] = $value;  | 
                                                        |
| 321 | + $obj[ $key ] = $value;  | 
                                                        |
| 322 | 322 | }  | 
                                                        
| 323 | 323 | return $obj;  | 
                                                        
| 324 | 324 | };  | 
                                                        
@@ -331,13 +331,13 @@ discard block  | 
                                                    ||
| 331 | 331 | */  | 
                                                        
| 332 | 332 | private function getUpdateChangeSetHandler()  | 
                                                        
| 333 | 333 |      { | 
                                                        
| 334 | -        return function ($key, $value, $obj) { | 
                                                        |
| 334 | +        return function($key, $value, $obj) { | 
                                                        |
| 335 | 335 | $op = '$set';  | 
                                                        
| 336 | 336 |              if (null === $value) { | 
                                                        
| 337 | 337 | $op = '$unset';  | 
                                                        
| 338 | 338 | $value = 1;  | 
                                                        
| 339 | 339 | }  | 
                                                        
| 340 | - $obj[$op][$key] = $value;  | 
                                                        |
| 340 | + $obj[ $op ][ $key ] = $value;  | 
                                                        |
| 341 | 341 | return $obj;  | 
                                                        
| 342 | 342 | };  | 
                                                        
| 343 | 343 | }  | 
                                                        
@@ -125,8 +125,8 @@ discard block  | 
                                                    ||
| 125 | 125 | $metadata = $this->getMetadata()->persistence;  | 
                                                        
| 126 | 126 | |
| 127 | 127 |          foreach ($metadata->schemata as $schema) { | 
                                                        
| 128 | - $this->assertTrue(isset($schema['options']['name']) && !empty($schema['options']['name']), 'index name was not applied to schema');  | 
                                                        |
| 129 | - $this->assertSame(stripos($schema['options']['name'], 'modlr_'), 0, '`modlr_` prefix missing from schema name');  | 
                                                        |
| 128 | + $this->assertTrue(isset($schema[ 'options' ][ 'name' ]) && !empty($schema[ 'options' ][ 'name' ]), 'index name was not applied to schema');  | 
                                                        |
| 129 | + $this->assertSame(stripos($schema[ 'options' ][ 'name' ], 'modlr_'), 0, '`modlr_` prefix missing from schema name');  | 
                                                        |
| 130 | 130 | }  | 
                                                        
| 131 | 131 | }  | 
                                                        
| 132 | 132 | |
@@ -136,7 +136,7 @@ discard block  | 
                                                    ||
| 136 | 136 | */  | 
                                                        
| 137 | 137 | public function testSchemaRequiresKeys()  | 
                                                        
| 138 | 138 |      { | 
                                                        
| 139 | - $schemata = [['options' => ['unique' => true]]];  | 
                                                        |
| 139 | + $schemata = [ [ 'options' => [ 'unique' => true ] ] ];  | 
                                                        |
| 140 | 140 | $metadata = $this->getMetadata($schemata);  | 
                                                        
| 141 | 141 | }  | 
                                                        
| 142 | 142 | |
@@ -146,7 +146,7 @@ discard block  | 
                                                    ||
| 146 | 146 | */  | 
                                                        
| 147 | 147 | public function testSchemaRequiresAtLeastOneKey()  | 
                                                        
| 148 | 148 |      { | 
                                                        
| 149 | - $schemata = ['keys' => [], ['options' => ['unique' => true]]];  | 
                                                        |
| 149 | + $schemata = [ 'keys' => [ ], [ 'options' => [ 'unique' => true ] ] ];  | 
                                                        |
| 150 | 150 | $metadata = $this->getMetadata($schemata);  | 
                                                        
| 151 | 151 | }  | 
                                                        
| 152 | 152 | |
@@ -160,7 +160,7 @@ discard block  | 
                                                    ||
| 160 | 160 | $manager = new Modlr\Persister\MongoDb\SchemaManager;  | 
                                                        
| 161 | 161 | |
| 162 | 162 | $schemata = [  | 
                                                        
| 163 | - ['options' => ['unique' => true]]  | 
                                                        |
| 163 | + [ 'options' => [ 'unique' => true ] ]  | 
                                                        |
| 164 | 164 | ];  | 
                                                        
| 165 | 165 | |
| 166 | 166 | $manager->createSchemata($collection, $schemata);  | 
                                                        
@@ -176,7 +176,7 @@ discard block  | 
                                                    ||
| 176 | 176 | $manager = new Modlr\Persister\MongoDb\SchemaManager;  | 
                                                        
| 177 | 177 | |
| 178 | 178 | $schemata = [  | 
                                                        
| 179 | - ['keys' => [], 'options' => ['unique' => true]]  | 
                                                        |
| 179 | + [ 'keys' => [ ], 'options' => [ 'unique' => true ] ]  | 
                                                        |
| 180 | 180 | ];  | 
                                                        
| 181 | 181 | |
| 182 | 182 | $manager->createSchemata($collection, $schemata);  | 
                                                        
@@ -193,36 +193,36 @@ discard block  | 
                                                    ||
| 193 | 193 |          foreach ($metadata->persistence->schemata as $schema) { | 
                                                        
| 194 | 194 | $found = false;  | 
                                                        
| 195 | 195 |              foreach ($indices as $index) { | 
                                                        
| 196 | -                if ($index['name'] === $schema['options']['name']) { | 
                                                        |
| 196 | +                if ($index[ 'name' ] === $schema[ 'options' ][ 'name' ]) { | 
                                                        |
| 197 | 197 | $found = true;  | 
                                                        
| 198 | 198 | }  | 
                                                        
| 199 | 199 | }  | 
                                                        
| 200 | -            $this->assertTrue($found, sprintf('Index for "%s" was not created!', $schema['options']['name'])); | 
                                                        |
| 200 | +            $this->assertTrue($found, sprintf('Index for "%s" was not created!', $schema[ 'options' ][ 'name' ])); | 
                                                        |
| 201 | 201 | }  | 
                                                        
| 202 | 202 | }  | 
                                                        
| 203 | 203 | |
| 204 | - private function getMetadata(array $schemata = [])  | 
                                                        |
| 204 | + private function getMetadata(array $schemata = [ ])  | 
                                                        |
| 205 | 205 |      { | 
                                                        
| 206 | 206 | $mapping = [  | 
                                                        
| 207 | 207 | 'type' => 'test-model',  | 
                                                        
| 208 | 208 | 'attributes' => [  | 
                                                        
| 209 | - 'name' => ['data_type' => 'string'],  | 
                                                        |
| 210 | - 'active' => ['data_type' => 'boolean']  | 
                                                        |
| 209 | + 'name' => [ 'data_type' => 'string' ],  | 
                                                        |
| 210 | + 'active' => [ 'data_type' => 'boolean' ]  | 
                                                        |
| 211 | 211 | ],  | 
                                                        
| 212 | 212 | 'persistence' => [  | 
                                                        
| 213 | 213 | 'db' => self::$dbName,  | 
                                                        
| 214 | 214 | 'collection' => 'test-model',  | 
                                                        
| 215 | 215 | 'schemata' => [  | 
                                                        
| 216 | - ['keys' => ['name' => 1]],  | 
                                                        |
| 217 | - ['keys' => ['active' => 1], ['options' => ['unique' => true]]]  | 
                                                        |
| 216 | + [ 'keys' => [ 'name' => 1 ] ],  | 
                                                        |
| 217 | + [ 'keys' => [ 'active' => 1 ], [ 'options' => [ 'unique' => true ] ] ]  | 
                                                        |
| 218 | 218 | ]  | 
                                                        
| 219 | 219 | ]  | 
                                                        
| 220 | 220 | ];  | 
                                                        
| 221 | 221 |          if (!empty($schemata)) { | 
                                                        
| 222 | - $mapping['persistence']['schemata'] = $schemata;  | 
                                                        |
| 222 | + $mapping[ 'persistence' ][ 'schemata' ] = $schemata;  | 
                                                        |
| 223 | 223 | }  | 
                                                        
| 224 | - $metadata = new Modlr\Metadata\EntityMetadata($mapping['type']);  | 
                                                        |
| 225 | - $pmd = $this->smf->createInstance($mapping['persistence']);  | 
                                                        |
| 224 | + $metadata = new Modlr\Metadata\EntityMetadata($mapping[ 'type' ]);  | 
                                                        |
| 225 | + $pmd = $this->smf->createInstance($mapping[ 'persistence' ]);  | 
                                                        |
| 226 | 226 | $metadata->setPersistence($pmd);  | 
                                                        
| 227 | 227 | $this->smf->handleValidate($metadata);  | 
                                                        
| 228 | 228 | return $metadata;  | 
                                                        
@@ -37,16 +37,16 @@ discard block  | 
                                                    ||
| 37 | 37 |      { | 
                                                        
| 38 | 38 | $persistence = new StorageMetadata();  | 
                                                        
| 39 | 39 | |
| 40 | -        if (isset($mapping['db'])) { | 
                                                        |
| 41 | - $persistence->db = $mapping['db'];  | 
                                                        |
| 40 | +        if (isset($mapping[ 'db' ])) { | 
                                                        |
| 41 | + $persistence->db = $mapping[ 'db' ];  | 
                                                        |
| 42 | 42 | }  | 
                                                        
| 43 | 43 | |
| 44 | -        if (isset($mapping['collection'])) { | 
                                                        |
| 45 | - $persistence->collection = $mapping['collection'];  | 
                                                        |
| 44 | +        if (isset($mapping[ 'collection' ])) { | 
                                                        |
| 45 | + $persistence->collection = $mapping[ 'collection' ];  | 
                                                        |
| 46 | 46 | }  | 
                                                        
| 47 | 47 | |
| 48 | -        if (isset($mapping['schemata'])) { | 
                                                        |
| 49 | - $persistence->schemata = $this->rksort($mapping['schemata']);  | 
                                                        |
| 48 | +        if (isset($mapping[ 'schemata' ])) { | 
                                                        |
| 49 | + $persistence->schemata = $this->rksort($mapping[ 'schemata' ]);  | 
                                                        |
| 50 | 50 | }  | 
                                                        
| 51 | 51 | return $persistence;  | 
                                                        
| 52 | 52 | }  | 
                                                        
@@ -82,7 +82,7 @@ discard block  | 
                                                    ||
| 82 | 82 | ksort($array);  | 
                                                        
| 83 | 83 |          foreach ($array as $k => $v) { | 
                                                        
| 84 | 84 |              if (is_array($v)) { | 
                                                        
| 85 | - $array[$k] = $this->rksort($v);  | 
                                                        |
| 85 | + $array[ $k ] = $this->rksort($v);  | 
                                                        |
| 86 | 86 | }  | 
                                                        
| 87 | 87 | }  | 
                                                        
| 88 | 88 | return $array;  | 
                                                        
@@ -131,7 +131,7 @@ discard block  | 
                                                    ||
| 131 | 131 | private function validateIdStrategy(EntityMetadata $metadata)  | 
                                                        
| 132 | 132 |      { | 
                                                        
| 133 | 133 | $persistence = $metadata->persistence;  | 
                                                        
| 134 | - $validIdStrategies = ['object'];  | 
                                                        |
| 134 | + $validIdStrategies = [ 'object' ];  | 
                                                        |
| 135 | 135 |          if (!in_array($persistence->idStrategy, $validIdStrategies)) { | 
                                                        
| 136 | 136 |              throw MetadataException::invalidMetadata($metadata->type, sprintf('The persistence id strategy "%s" is invalid. Valid types are "%s"', $persistence->idStrategy, implode('", "', $validIdStrategies))); | 
                                                        
| 137 | 137 | }  | 
                                                        
@@ -147,10 +147,10 @@ discard block  | 
                                                    ||
| 147 | 147 |      { | 
                                                        
| 148 | 148 | $persistence = $metadata->persistence;  | 
                                                        
| 149 | 149 |          foreach ($persistence->schemata as $k => $schema) { | 
                                                        
| 150 | -            if (!isset($schema['keys']) || empty($schema['keys'])) { | 
                                                        |
| 150 | +            if (!isset($schema[ 'keys' ]) || empty($schema[ 'keys' ])) { | 
                                                        |
| 151 | 151 | throw MetadataException::invalidMetadata($metadata->type, 'At least one key must be specified to define an index.');  | 
                                                        
| 152 | 152 | }  | 
                                                        
| 153 | -            $persistence->schemata[$k]['options']['name'] = sprintf('modlr_%s', md5(json_encode($schema))); | 
                                                        |
| 153 | +            $persistence->schemata[ $k ][ 'options' ][ 'name' ] = sprintf('modlr_%s', md5(json_encode($schema))); | 
                                                        |
| 154 | 154 | }  | 
                                                        
| 155 | 155 | }  | 
                                                        
| 156 | 156 | }  | 
                                                        
@@ -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 | |
@@ -162,7 +162,7 @@ discard block  | 
                                                    ||
| 162 | 162 | ];  | 
                                                        
| 163 | 163 |          if (true === $related->isChildEntity()) { | 
                                                        
| 164 | 164 | // The relationship is owned by a polymorphic model. Must include the type in the root criteria.  | 
                                                        
| 165 | - $criteria[Persister::POLYMORPHIC_KEY] = $related->type;  | 
                                                        |
| 165 | + $criteria[ Persister::POLYMORPHIC_KEY ] = $related->type;  | 
                                                        |
| 166 | 166 | }  | 
                                                        
| 167 | 167 | return $criteria;  | 
                                                        
| 168 | 168 | }  | 
                                                        
@@ -190,18 +190,18 @@ discard block  | 
                                                    ||
| 190 | 190 | */  | 
                                                        
| 191 | 191 | public function getRetrieveCritiera(EntityMetadata $metadata, $identifiers = null)  | 
                                                        
| 192 | 192 |      { | 
                                                        
| 193 | - $criteria = [];  | 
                                                        |
| 193 | + $criteria = [ ];  | 
                                                        |
| 194 | 194 |          if (true === $metadata->isChildEntity()) { | 
                                                        
| 195 | - $criteria[Persister::POLYMORPHIC_KEY] = $metadata->type;  | 
                                                        |
| 195 | + $criteria[ Persister::POLYMORPHIC_KEY ] = $metadata->type;  | 
                                                        |
| 196 | 196 |          } elseif (true === $metadata->isPolymorphic() && false === $metadata->isAbstract()) { | 
                                                        
| 197 | - $criteria[Persister::POLYMORPHIC_KEY] = $metadata->type;  | 
                                                        |
| 197 | + $criteria[ Persister::POLYMORPHIC_KEY ] = $metadata->type;  | 
                                                        |
| 198 | 198 | }  | 
                                                        
| 199 | 199 | |
| 200 | 200 | $identifiers = (array) $identifiers;  | 
                                                        
| 201 | 201 |          if (empty($identifiers)) { | 
                                                        
| 202 | 202 | return $criteria;  | 
                                                        
| 203 | 203 | }  | 
                                                        
| 204 | - $criteria[Persister::IDENTIFIER_KEY] = (1 === count($identifiers)) ? reset($identifiers) : $identifiers;  | 
                                                        |
| 204 | + $criteria[ Persister::IDENTIFIER_KEY ] = (1 === count($identifiers)) ? reset($identifiers) : $identifiers;  | 
                                                        |
| 205 | 205 | return $criteria;  | 
                                                        
| 206 | 206 | }  | 
                                                        
| 207 | 207 | |
@@ -285,7 +285,7 @@ discard block  | 
                                                    ||
| 285 | 285 | */  | 
                                                        
| 286 | 286 | private function isSearchQuery(array $criteria)  | 
                                                        
| 287 | 287 |      { | 
                                                        
| 288 | -        if (isset($criteria['$text'])) { | 
                                                        |
| 288 | +        if (isset($criteria[ '$text' ])) { | 
                                                        |
| 289 | 289 | return true;  | 
                                                        
| 290 | 290 | }  | 
                                                        
| 291 | 291 |          foreach ($criteria as $key => $value) { | 
                                                        
@@ -314,8 +314,8 @@ discard block  | 
                                                    ||
| 314 | 314 |              if ($type !== $include) { | 
                                                        
| 315 | 315 |                  PersisterException::badRequest('Field projection mismatch. You cannot both exclude and include fields.'); | 
                                                        
| 316 | 316 | }  | 
                                                        
| 317 | - $fields[$key] = $type;  | 
                                                        |
| 317 | + $fields[ $key ] = $type;  | 
                                                        |
| 318 | 318 | }  | 
                                                        
| 319 | - return [$fields, $include];  | 
                                                        |
| 319 | + return [ $fields, $include ];  | 
                                                        |
| 320 | 320 | }  | 
                                                        
| 321 | 321 | }  |