Passed
Push — master ( d8e957...a3e243 )
by Maksim
03:45
created
tests/CompositeToCompositeRelationTest.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,8 +55,7 @@
 block discarded – undo
55 55
 
56 56
         try {
57 57
             $user->wrongConfiguredReferrer()->first();
58
-        }
59
-        catch (\Exception $exception) {
58
+        } catch (\Exception $exception) {
60 59
             $this->assertInstanceOf(WrongRelationConfigurationException::class, $exception);
61 60
         }
62 61
     }
Please login to merge, or discard this patch.
tests/database/migrations/2014_10_12_000000_create_users_table.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
      */
12 12
     public function up()
13 13
     {
14
-        Schema::create('users', function (Blueprint $table) {
14
+        Schema::create('users', function(Blueprint $table) {
15 15
             //primary
16 16
             $table->unsignedInteger('user_id');
17 17
             $table->unsignedInteger('organization_id');
Please login to merge, or discard this patch.
src/Scopes/CompositeKeyScope.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,14 +38,14 @@
 block discarded – undo
38 38
      */
39 39
     public function apply($query)
40 40
     {
41
-        $query->where(function ($query) {
41
+        $query->where(function($query) {
42 42
             foreach ($this->ids as $compositeKey) {
43 43
                 // try to parse normalized key
44 44
                 if (!is_array($compositeKey)) {
45 45
                     $compositeKey = $this->parseNormalizedKey($compositeKey);
46 46
                 }
47 47
 
48
-                $queryWriter = function ($query) use ($compositeKey) {
48
+                $queryWriter = function($query) use ($compositeKey) {
49 49
                     /*
50 50
                      * @var \Illuminate\Database\Query\Builder $query
51 51
                      */
Please login to merge, or discard this patch.
src/Http/Traits/HasCompositePrimaryKey.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -165,7 +165,7 @@
 block discarded – undo
165 165
 
166 166
         return $this->newQueryWithoutScopes()->applyIds(
167 167
             array_map(
168
-                function ($normalizedKey) {
168
+                function($normalizedKey) {
169 169
                     return $this->parseNormalizedKey($normalizedKey);
170 170
                 },
171 171
                 $ids
Please login to merge, or discard this patch.
src/Eloquent/Relationships/CompositeBelongsTo.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
             $ownerKeys = $this->getOwnerKeys();
30 30
             $foreignKeys = $this->getForeignKeys();
31 31
 
32
-            if(count($ownerKeys)!=count($foreignKeys))
32
+            if (count($ownerKeys) != count($foreignKeys))
33 33
                 throw new WrongRelationConfigurationException();
34 34
 
35 35
             foreach ($ownerKeys as $keyIndex => $key)
@@ -50,21 +50,21 @@  discard block
 block discarded – undo
50 50
         // We'll grab the primary key name of the related models since it could be set to
51 51
         // a non-standard name and not "id". We will then construct the constraint for
52 52
         // our eagerly loading query so it returns the proper models from execution.
53
-        (new CompositeKeyScope(array_map(function($keyName){
53
+        (new CompositeKeyScope(array_map(function($keyName) {
54 54
             return  $this->related->getTable().'.'.$keyName;
55
-        }, $ownerKeys), $this->getEagerModelKeys($models), false, method_exists($this->related,'getBinaryColumns') ? $this->related->getBinaryColumns() : []))->apply($this->query);
55
+        }, $ownerKeys), $this->getEagerModelKeys($models), false, method_exists($this->related, 'getBinaryColumns') ? $this->related->getBinaryColumns() : []))->apply($this->query);
56 56
     }
57 57
 
58 58
     public function getOwnerKeys()
59 59
     {
60
-        if(method_exists($this->parent, 'hasCompositeIndex') && $this->parent->hasCompositeIndex() && !is_array($this->ownerKey) && strpos($this->ownerKey,$this->magicKeyDelimiter) !== false)
60
+        if (method_exists($this->parent, 'hasCompositeIndex') && $this->parent->hasCompositeIndex() && !is_array($this->ownerKey) && strpos($this->ownerKey, $this->magicKeyDelimiter) !== false)
61 61
             $this->ownerKey = explode($this->magicKeyDelimiter, $this->ownerKey);
62 62
         return !is_array($this->ownerKey) ? [$this->ownerKey] : $this->ownerKey;
63 63
     }
64 64
 
65 65
     public function getForeignKeys()
66 66
     {
67
-        if(method_exists($this->related, 'hasCompositeIndex') && $this->related->hasCompositeIndex() && !is_array($this->foreignKey) && strpos($this->foreignKey,$this->magicKeyDelimiter) !== false)
67
+        if (method_exists($this->related, 'hasCompositeIndex') && $this->related->hasCompositeIndex() && !is_array($this->foreignKey) && strpos($this->foreignKey, $this->magicKeyDelimiter) !== false)
68 68
             $this->foreignKey = explode($this->magicKeyDelimiter, $this->foreignKey);
69 69
         return !is_array($this->foreignKey) ? [$this->foreignKey] : $this->foreignKey;
70 70
     }
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
             $keys[] = $compositeKey;
96 96
         }
97 97
 
98
-        if(count($foreignKeys) == 1) {
98
+        if (count($foreignKeys) == 1) {
99 99
             // If there are no keys that were not null we will just return an array with null
100 100
             // so this query wont fail plus returns zero results, which should be what the
101 101
             // developer expects to happen in this situation. Otherwise we'll sort them.
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
         $dictionary = [];
132 132
 
133 133
         foreach ($results as $result) {
134
-            $dictionary[implode($this->magicKeyDelimiter,array_map(function($owner) use ($result) {
134
+            $dictionary[implode($this->magicKeyDelimiter, array_map(function($owner) use ($result) {
135 135
                 return $result->getAttribute($owner);
136 136
             }, $ownerKeys))] = $result;
137 137
         }
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
         // and match back onto their children using these keys of the dictionary and
141 141
         // the primary key of the children to map them onto the correct instances.
142 142
         foreach ($models as $model) {
143
-            $foreignKey = implode($this->magicKeyDelimiter,array_map(function($foreign) use ($model) {
143
+            $foreignKey = implode($this->magicKeyDelimiter, array_map(function($foreign) use ($model) {
144 144
                 return $model->{$foreign};
145 145
             }, $foreignKeys));
146 146
             if (isset($dictionary[$foreignKey])) {
Please login to merge, or discard this patch.
Braces   +14 added lines, -10 removed lines patch added patch discarded remove patch
@@ -29,11 +29,13 @@  discard block
 block discarded – undo
29 29
             $ownerKeys = $this->getOwnerKeys();
30 30
             $foreignKeys = $this->getForeignKeys();
31 31
 
32
-            if(count($ownerKeys)!=count($foreignKeys))
33
-                throw new WrongRelationConfigurationException();
32
+            if(count($ownerKeys)!=count($foreignKeys)) {
33
+                            throw new WrongRelationConfigurationException();
34
+            }
34 35
 
35
-            foreach ($ownerKeys as $keyIndex => $key)
36
-                $this->query->where($table.'.'.$key, '=', $this->child->{$foreignKeys[$keyIndex]});
36
+            foreach ($ownerKeys as $keyIndex => $key) {
37
+                            $this->query->where($table.'.'.$key, '=', $this->child->{$foreignKeys[$keyIndex]});
38
+            }
37 39
         }
38 40
     }
39 41
 
@@ -57,15 +59,17 @@  discard block
 block discarded – undo
57 59
 
58 60
     public function getOwnerKeys()
59 61
     {
60
-        if(method_exists($this->parent, 'hasCompositeIndex') && $this->parent->hasCompositeIndex() && !is_array($this->ownerKey) && strpos($this->ownerKey,$this->magicKeyDelimiter) !== false)
61
-            $this->ownerKey = explode($this->magicKeyDelimiter, $this->ownerKey);
62
+        if(method_exists($this->parent, 'hasCompositeIndex') && $this->parent->hasCompositeIndex() && !is_array($this->ownerKey) && strpos($this->ownerKey,$this->magicKeyDelimiter) !== false) {
63
+                    $this->ownerKey = explode($this->magicKeyDelimiter, $this->ownerKey);
64
+        }
62 65
         return !is_array($this->ownerKey) ? [$this->ownerKey] : $this->ownerKey;
63 66
     }
64 67
 
65 68
     public function getForeignKeys()
66 69
     {
67
-        if(method_exists($this->related, 'hasCompositeIndex') && $this->related->hasCompositeIndex() && !is_array($this->foreignKey) && strpos($this->foreignKey,$this->magicKeyDelimiter) !== false)
68
-            $this->foreignKey = explode($this->magicKeyDelimiter, $this->foreignKey);
70
+        if(method_exists($this->related, 'hasCompositeIndex') && $this->related->hasCompositeIndex() && !is_array($this->foreignKey) && strpos($this->foreignKey,$this->magicKeyDelimiter) !== false) {
71
+                    $this->foreignKey = explode($this->magicKeyDelimiter, $this->foreignKey);
72
+        }
69 73
         return !is_array($this->foreignKey) ? [$this->foreignKey] : $this->foreignKey;
70 74
     }
71 75
 
@@ -106,9 +110,9 @@  discard block
 block discarded – undo
106 110
             sort($keys);
107 111
 
108 112
             return array_values(array_unique($keys));
113
+        } else {
114
+                    return $keys;
109 115
         }
110
-        else
111
-            return $keys;
112 116
     }
113 117
 
114 118
     /**
Please login to merge, or discard this patch.