Passed
Pull Request — master (#5)
by Maksim
05:00
created
src/Eloquent/Relationships/CompositeBelongsTo.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
     public function getResults()
47 47
     {
48 48
         $foreignKey = !is_array($this->foreignKey) ? [$this->foreignKey] : $this->foreignKey;
49
-        foreach($foreignKey as $foreignKeyVal) {
49
+        foreach ($foreignKey as $foreignKeyVal) {
50 50
             if (is_null($this->child->{$foreignKeyVal})) {
51 51
                 return $this->getDefaultFor($this->parent);
52 52
             }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         // We'll grab the primary key name of the related models since it could be set to
70 70
         // a non-standard name and not "id". We will then construct the constraint for
71 71
         // our eagerly loading query so it returns the proper models from execution.
72
-        (new CompositeKeyScope(array_map(function ($keyName) {
72
+        (new CompositeKeyScope(array_map(function($keyName) {
73 73
             return  $this->related->getTable().'.'.$keyName;
74 74
         }, $ownerKeys), $this->getEagerModelKeys($models), false, method_exists($this->related, 'getBinaryColumns') ? $this->related->getBinaryColumns() : []))->apply($this->query);
75 75
     }
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
         $dictionary = [];
151 151
 
152 152
         foreach ($results as $result) {
153
-            $dictionary[implode($this->magicKeyDelimiter, array_map(function ($owner) use ($result) {
153
+            $dictionary[implode($this->magicKeyDelimiter, array_map(function($owner) use ($result) {
154 154
                 return $result->getAttribute($owner);
155 155
             }, $ownerKeys))] = $result;
156 156
         }
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
         // and match back onto their children using these keys of the dictionary and
160 160
         // the primary key of the children to map them onto the correct instances.
161 161
         foreach ($models as $model) {
162
-            $foreignKey = implode($this->magicKeyDelimiter, array_map(function ($foreign) use ($model) {
162
+            $foreignKey = implode($this->magicKeyDelimiter, array_map(function($foreign) use ($model) {
163 163
                 return $model->{$foreign};
164 164
             }, $foreignKeys));
165 165
             if (isset($dictionary[$foreignKey])) {
Please login to merge, or discard this patch.
src/Http/Traits/NormalizedKeysParser.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
         $rawKeys = $this->getRawKey();
51 51
 
52 52
         //do not normalize single key because we couldn't detect its type
53
-        if(count($rawKeys) > 1) {
53
+        if (count($rawKeys) > 1) {
54 54
             foreach ($rawKeys as $key => $value) {
55 55
                 if (in_array($key, $this->getBinaryColumns()) && !$this->hexBinaryColumns()) {
56 56
                     $rawKeys[$key] = strtoupper(bin2hex($value));
Please login to merge, or discard this patch.
src/Http/Traits/HasCompositePrimaryKey.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
             (new CompositeKeyScope($keys, $ids, $inverse, $this->getBinaryColumns()))->apply($query);
140 140
         } else {
141 141
             //remap hex ID to binary ID even if index is not composite
142
-            if($this->shouldProcessBinaryAttribute($keys[0]))
143
-                $ids = array_map(function($hex){
142
+            if ($this->shouldProcessBinaryAttribute($keys[0]))
143
+                $ids = array_map(function($hex) {
144 144
                     return hex2bin($hex);
145 145
                 }, $ids);
146 146
             if ($inverse) {
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 
170 170
         return $this->newQueryWithoutScopes()->applyIds(
171 171
             array_map(
172
-                function ($normalizedKey) {
172
+                function($normalizedKey) {
173 173
                     return $this->parseNormalizedKey($normalizedKey);
174 174
                 },
175 175
                 $ids
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
         }
275 275
     }
276 276
     
277
-    private function shouldProcessBinaryAttribute($key){
277
+    private function shouldProcessBinaryAttribute($key) {
278 278
         return $this->hexBinaryColumns() && in_array($key, $this->getBinaryColumns());
279 279
     }
280 280
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -139,9 +139,10 @@
 block discarded – undo
139 139
             (new CompositeKeyScope($keys, $ids, $inverse, $this->getBinaryColumns()))->apply($query);
140 140
         } else {
141 141
             //remap hex ID to binary ID even if index is not composite
142
-            if($this->shouldProcessBinaryAttribute($keys[0]))
143
-                $ids = array_map(function($hex){
142
+            if($this->shouldProcessBinaryAttribute($keys[0])) {
143
+                            $ids = array_map(function($hex){
144 144
                     return hex2bin($hex);
145
+            }
145 146
                 }, $ids);
146 147
             if ($inverse) {
147 148
                 $query->whereNotIn($this->qualifyColumn($keys[0]), $ids);
Please login to merge, or discard this patch.
src/Scopes/CompositeKeyScope.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public function apply($query)
42 42
     {
43
-        $query->where(function ($query) {
43
+        $query->where(function($query) {
44 44
             foreach ($this->ids as $compositeKey) {
45 45
                 // try to parse normalized key
46 46
                 if (!is_array($compositeKey)) {
47 47
                     $compositeKey = $this->parseNormalizedKey($compositeKey);
48 48
                 } else {
49
-                    if(method_exists($query->getModel(), 'hexBinaryColumns') && $query->getModel()->hexBinaryColumns()) {
49
+                    if (method_exists($query->getModel(), 'hexBinaryColumns') && $query->getModel()->hexBinaryColumns()) {
50 50
                         foreach ($compositeKey as $key => $value) {
51 51
                             $compositeKey[$key] = in_array($key, $this->getBinaryColumns()) ? $this->recoverBinaryKey(
52 52
                                 $key,
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
                     }
57 57
                 }
58 58
 
59
-                $queryWriter = function ($query) use ($compositeKey) {
59
+                $queryWriter = function($query) use ($compositeKey) {
60 60
                     /*
61 61
                      * @var \Illuminate\Database\Query\Builder $query
62 62
                      */
Please login to merge, or discard this patch.
tests/CompositeKeyBaseUnit.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
         if (env('DEBUG_QUERY_LOG', true)) {
39 39
             DB::listen(
40
-                function (QueryExecuted $queryExecuted) {
40
+                function(QueryExecuted $queryExecuted) {
41 41
                     var_dump($queryExecuted->sql);
42 42
                     var_dump($queryExecuted->bindings);
43 43
                 }
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
     protected function loadMigrationsFrom($paths): void
59 59
     {
60 60
         $paths = (is_array($paths)) ? $paths : [$paths];
61
-        $this->app->afterResolving('migrator', function ($migrator) use ($paths) {
61
+        $this->app->afterResolving('migrator', function($migrator) use ($paths) {
62 62
             foreach ((array) $paths as $path) {
63 63
                 $migrator->path($path);
64 64
             }
Please login to merge, or discard this patch.
tests/Stubs/TestRole.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@
 block discarded – undo
17 17
         'name',
18 18
     ];
19 19
 
20
-    public function users(){
20
+    public function users() {
21 21
         return $this->hasMany(TestBinaryUser::class, 'role_id', 'role_id');
22 22
     }
23 23
 
24
-    public function hex_users(){
24
+    public function hex_users() {
25 25
         return $this->hasMany(TestBinaryUserHex::class, 'role_id', 'role_id');
26 26
     }
27 27
 
Please login to merge, or discard this patch.
tests/Stubs/TestBinaryRole.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,11 +24,11 @@
 block discarded – undo
24 24
         'name',
25 25
     ];
26 26
 
27
-    public function users(){
27
+    public function users() {
28 28
         return $this->hasMany(TestBinaryUser::class, 'binary_role_id', 'role_id');
29 29
     }
30 30
 
31
-    public function hex_users(){
31
+    public function hex_users() {
32 32
         return $this->hasMany(TestBinaryUserHex::class, 'binary_role_id', 'role_id');
33 33
     }
34 34
 
Please login to merge, or discard this patch.
tests/SingleKeyBinaryModelTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
      */
50 50
     public function validateEagerRelations(TestBinaryRole $model)
51 51
     {
52
-        $model->loadMissing(['users','hex_users']);
52
+        $model->loadMissing(['users', 'hex_users']);
53 53
         $this->assertNotNull($model->toArray()['users']);
54 54
         $this->assertNotNull($model->toArray()['hex_users']);
55 55
         $this->assertNotNull($model->users);
Please login to merge, or discard this patch.
tests/SingleKeyBinaryModelHexTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
      */
50 50
     public function validateEagerRelations(TestBinaryRoleHex $model)
51 51
     {
52
-        $model->loadMissing(['users','hex_users']);
52
+        $model->loadMissing(['users', 'hex_users']);
53 53
         $this->assertNotNull($model->toArray()['users']);
54 54
         $this->assertNotNull($model->toArray()['hex_users']);
55 55
         $this->assertNotNull($model->users);
Please login to merge, or discard this patch.