@@ -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 | }  |