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.
src/Eloquent/Relationships/CompositeBelongsTo.php 1 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.