Completed
Push — master ( 20e1fc...2f76e5 )
by Ivan
02:17
created
src/schema/Mapper.php 2 patches
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,6 +43,10 @@  discard block
 block discarded – undo
43 43
             protected $changed = [];
44 44
             protected $fetched = [];
45 45
 
46
+            /**
47
+             * @param Mapper $mapper
48
+             * @param Table $definition
49
+             */
46 50
             public function __construct($mapper, $definition, array $data = [])
47 51
             {
48 52
                 $this->mapper = $mapper;
@@ -156,7 +160,7 @@  discard block
 block discarded – undo
156 160
     /**
157 161
      * Get a collection of entities
158 162
      *
159
-     * @param TableQuery $iterator
163
+     * @param TableQueryIterator $iterator
160 164
      * @param Table $definition
161 165
      * @return Collection
162 166
      */
Please login to merge, or discard this patch.
Spacing   +8 added lines, -11 removed lines patch added patch discarded remove patch
@@ -64,8 +64,7 @@  discard block
 block discarded – undo
64 64
                 }
65 65
                 if (isset($this->fetched[$property])) {
66 66
                     return is_callable($this->fetched[$property]) ?
67
-                        $this->fetched[$property] = call_user_func($this->fetched[$property]) :
68
-                        $this->fetched[$property];
67
+                        $this->fetched[$property] = call_user_func($this->fetched[$property]) : $this->fetched[$property];
69 68
                 }
70 69
                 return null;
71 70
             }
@@ -78,8 +77,7 @@  discard block
 block discarded – undo
78 77
                 if (isset($this->definition->getRelations()[$method])) {
79 78
                     if (isset($this->fetched[$method])) {
80 79
                         return is_callable($this->fetched[$method]) ?
81
-                            $this->fetched[$method] = call_user_func($this->fetched[$method], $args[0] ?? null) :
82
-                            $this->fetched[$method];
80
+                            $this->fetched[$method] = call_user_func($this->fetched[$method], $args[0] ?? null) : $this->fetched[$method];
83 81
                     }
84 82
                 }
85 83
                 return null;
@@ -163,7 +161,7 @@  discard block
 block discarded – undo
163 161
     public function collection(TableQueryIterator $iterator, Table $definition) : Collection
164 162
     {
165 163
         return Collection::from($iterator)
166
-            ->map(function ($v) use ($definition) {
164
+            ->map(function($v) use ($definition) {
167 165
                 return $this->entity($definition, $v);
168 166
             });
169 167
     }
@@ -238,7 +236,7 @@  discard block
 block discarded – undo
238 236
         $definition = $entity->definition();
239 237
         foreach ($definition->getColumns() as $column) {
240 238
             if (!isset($data[$column])) {
241
-                $entity->__lazyProperty($column, function () use ($entity, $definition, $primary, $column) {
239
+                $entity->__lazyProperty($column, function() use ($entity, $definition, $primary, $column) {
242 240
                     $query = $this->db->table($definition->getName());
243 241
                     foreach ($primary as $k => $v) {
244 242
                         $query->filter($k, $v);
@@ -250,12 +248,12 @@  discard block
 block discarded – undo
250 248
         foreach ($definition->getRelations() as $name => $relation) {
251 249
             if (isset($data[$name])) {
252 250
                 $entity->{$name} = $relation->many ? 
253
-                    array_map(function ($v) use ($relation) {
251
+                    array_map(function($v) use ($relation) {
254 252
                         return $this->entity($relation->table, $v);
255 253
                     }, $data[$name]) :
256 254
                     $this->entity($relation->table, $data[$name]);
257 255
             } else {
258
-                $entity->__lazyProperty($name, function (array $columns = null) use ($entity, $definition, $primary, $relation, $data) {
256
+                $entity->__lazyProperty($name, function(array $columns = null) use ($entity, $definition, $primary, $relation, $data) {
259 257
                     $query = $this->db->table($relation->table->getName(), true);
260 258
                     if ($columns !== null) {
261 259
                         $query->columns($columns);
@@ -281,7 +279,7 @@  discard block
 block discarded – undo
281 279
                             );
282 280
                         }
283 281
                         foreach ($definition->getPrimaryKey() as $v) {
284
-                            $query->filter($nm . '.' . $v, $data[$v] ?? null);
282
+                            $query->filter($nm.'.'.$v, $data[$v] ?? null);
285 283
                         }
286 284
                     } else {
287 285
                         foreach ($relation->keymap as $k => $v) {
@@ -289,8 +287,7 @@  discard block
 block discarded – undo
289 287
                         }
290 288
                     }
291 289
                     return $relation->many ?
292
-                        $query->iterator() :
293
-                        $query[0];
290
+                        $query->iterator() : $query[0];
294 291
                 });
295 292
             }
296 293
         }
Please login to merge, or discard this patch.