Passed
Pull Request — master (#221)
by Christopher
06:11
created
src/Models/ObjectMap/Entities/Associations/AssociationStubFactory.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -234,7 +234,7 @@
 block discarded – undo
234 234
                     $segments = explode('.', $this->{$item});
235 235
                     $carry[] = end($segments);
236 236
 
237
-             }
237
+                }
238 238
             return $carry;
239 239
         };
240 240
         return call_user_func($getter->bindTo($relation, Relation::class));
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         $stub->setBaseType(get_class(self::getParent($relation)));
70 70
         $stub->setRelationName($name);
71 71
         $stub->setThroughFieldChain($keyChain);
72
-        $stub->setKeyField($keyChain[0] ?: $relation->getRelated()->getKeyName() );
72
+        $stub->setKeyField($keyChain[0] ?: $relation->getRelated()->getKeyName());
73 73
         $stub->setForeignField($keyChain[0]);
74 74
         $stub->setMultiplicity(AssociationStubRelationType::ONE());
75 75
         $stub->setTargType(null);
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      * @return AssociationStubBase
103 103
      */
104 104
     protected static function handleHasManyThrough(string $name, Relation $relation, $cacheKey = 'HasManyThrough'):AssociationStubBase{
105
-        $farParentGetter = function(){
105
+        $farParentGetter = function () {
106 106
             return $this->farParent;
107 107
         };
108 108
         $farParent = call_user_func($farParentGetter->bindTo($relation, HasManyThrough::class));
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      * @return AssociationStubBase
127 127
      */
128 128
     protected static function handleMorphToMany(string $name, Relation $relation, $cacheKey = 'BelongsToMany'): AssociationStubBase{
129
-        $inverseGetter = function(){
129
+        $inverseGetter = function () {
130 130
             return $this->inverse;
131 131
         };
132 132
         $inverse = call_user_func($inverseGetter->bindTo($relation, MorphToMany::class));
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
214 214
         return $stub;
215 215
     }
216 216
 
217
-    private static function getParent(Relation $relation){
218
-        $getter = function(){
217
+    private static function getParent(Relation $relation) {
218
+        $getter = function () {
219 219
             return $this->parent;
220 220
         };
221 221
         return call_user_func($getter->bindTo($relation, Relation::class));
@@ -223,11 +223,11 @@  discard block
 block discarded – undo
223 223
 
224 224
     private static function getKeyChain(Relation $relation, string $cacheKey) : array {
225 225
         $fields = self::$fieldOrderCache[$cacheKey];
226
-        $getter =  function() use ($fields){
226
+        $getter = function () use ($fields){
227 227
             $carry = [];
228
-            foreach($fields as $item){
228
+            foreach ($fields as $item) {
229 229
                     $v = $this->{$item};
230
-                    if($v == null && $item == 'ownerKey'){
230
+                    if ($v == null && $item == 'ownerKey') {
231 231
                         $carry[] = null;
232 232
                         continue;
233 233
                     }
@@ -242,8 +242,8 @@  discard block
 block discarded – undo
242 242
 
243 243
     private static $fieldOrderCache = [
244 244
         'BelongsTo' => ['ownerKey', 'foreignKey'],
245
-        'BelongsToMany' => ['parentKey','foreignPivotKey','relatedPivotKey','relatedKey'],
246
-        'HasOneOrMany' => ['localKey', 'foreignKey' ],
245
+        'BelongsToMany' => ['parentKey', 'foreignPivotKey', 'relatedPivotKey', 'relatedKey'],
246
+        'HasOneOrMany' => ['localKey', 'foreignKey'],
247 247
         'HasManyThrough' => ['localKey', 'firstKey', 'secondLocalKey', 'secondKey'],
248 248
 
249 249
     ];
Please login to merge, or discard this patch.
Braces   +8 added lines, -7 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      * @return AssociationStubBase
103 103
      */
104 104
     protected static function handleHasManyThrough(string $name, Relation $relation, $cacheKey = 'HasManyThrough'):AssociationStubBase{
105
-        $farParentGetter = function(){
105
+        $farParentGetter = function() {
106 106
             return $this->farParent;
107 107
         };
108 108
         $farParent = call_user_func($farParentGetter->bindTo($relation, HasManyThrough::class));
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      * @return AssociationStubBase
127 127
      */
128 128
     protected static function handleMorphToMany(string $name, Relation $relation, $cacheKey = 'BelongsToMany'): AssociationStubBase{
129
-        $inverseGetter = function(){
129
+        $inverseGetter = function() {
130 130
             return $this->inverse;
131 131
         };
132 132
         $inverse = call_user_func($inverseGetter->bindTo($relation, MorphToMany::class));
@@ -214,8 +214,9 @@  discard block
 block discarded – undo
214 214
         return $stub;
215 215
     }
216 216
 
217
-    private static function getParent(Relation $relation){
218
-        $getter = function(){
217
+    private static function getParent(Relation $relation)
218
+    {
219
+        $getter = function() {
219 220
             return $this->parent;
220 221
         };
221 222
         return call_user_func($getter->bindTo($relation, Relation::class));
@@ -223,11 +224,11 @@  discard block
 block discarded – undo
223 224
 
224 225
     private static function getKeyChain(Relation $relation, string $cacheKey) : array {
225 226
         $fields = self::$fieldOrderCache[$cacheKey];
226
-        $getter =  function() use ($fields){
227
+        $getter =  function() use ($fields) {
227 228
             $carry = [];
228
-            foreach($fields as $item){
229
+            foreach($fields as $item) {
229 230
                     $v = $this->{$item};
230
-                    if($v == null && $item == 'ownerKey'){
231
+                    if($v == null && $item == 'ownerKey') {
231 232
                         $carry[] = null;
232 233
                         continue;
233 234
                     }
Please login to merge, or discard this patch.
src/Models/MetadataRelationsTrait.php 1 patch
Spacing   +7 added lines, -9 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      */
34 34
     public function getRelationships($temping = false)
35 35
     {
36
-        if($temping) {
36
+        if ($temping) {
37 37
             $rels = $this->getRelationshipsFromMethods(true);
38 38
             return array_unique(array_merge(
39 39
                 array_keys($rels['UnknownPolyMorphSide']),
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
         $fileName = $method->getFileName();
99 99
 
100 100
         $file = new \SplFileObject($fileName);
101
-        $file->seek($method->getStartLine() - 1);
101
+        $file->seek($method->getStartLine()-1);
102 102
         $code = '';
103 103
         while ($file->key() < $method->getEndLine()) {
104 104
             $code .= $file->current();
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
             throw new InvalidOperationException($msg);
112 112
         }
113 113
         $begin = strpos($code, 'function(');
114
-        $code = substr($code, $begin, strrpos($code, '}') - $begin + 1);
115
-        $lastCode = $code[strlen($code) - 1];
114
+        $code = substr($code, $begin, strrpos($code, '}')-$begin+1);
115
+        $lastCode = $code[strlen($code)-1];
116 116
         if ('}' != $lastCode) {
117 117
             $msg = 'Final character of function definition must be closing brace';
118 118
             throw new InvalidOperationException($msg);
@@ -157,11 +157,10 @@  discard block
 block discarded – undo
157 157
                     continue;
158 158
                 }
159 159
                 $targetClass = $relation == 'morphTo' ?
160
-                    '\Illuminate\Database\Eloquent\Model|\Eloquent' :
161
-                    '\\' . get_class($relObject);
160
+                    '\Illuminate\Database\Eloquent\Model|\Eloquent' : '\\' . get_class($relObject);
162 161
                 $targObject = $biDir ? $relationObj : $targetClass;
163 162
                 $relToKeyMap = [
164
-                    'morphedByMany' => ['UnknownPolyMorphSide','HasMany'],
163
+                    'morphedByMany' => ['UnknownPolyMorphSide', 'HasMany'],
165 164
                     'morphToMany' => ['KnownPolyMorphSide', 'HasMany'],
166 165
                     'morphMany' => ['KnownPolyMorphSide', 'HasMany'],
167 166
                     'hasMany' => ['HasMany'],
@@ -200,8 +199,7 @@  discard block
 block discarded – undo
200 199
             $keyName = $this->polyglotFkKey($relation);
201 200
             $localName = $this->polyglotRkKey($relation);
202 201
             $thruName = $relation instanceof HasManyThrough ?
203
-                $this->polyglotThroughKey($relation) :
204
-                null;
202
+                $this->polyglotThroughKey($relation) : null;
205 203
 
206 204
             $first = $keyName;
207 205
             $last = $localName;
Please login to merge, or discard this patch.