@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @param EntityGubbins $entity |
| 16 | 16 | */ |
| 17 | - public function addEntity(EntityGubbins $entity): void ; |
|
| 17 | + public function addEntity(EntityGubbins $entity): void; |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * returns all Relation Stubs that are permitted at the other end. |
@@ -46,5 +46,5 @@ discard block |
||
| 46 | 46 | * @param string $className |
| 47 | 47 | * @return bool |
| 48 | 48 | */ |
| 49 | - public function hasClass(string $className): bool ; |
|
| 49 | + public function hasClass(string $className): bool; |
|
| 50 | 50 | } |
| 51 | 51 | \ No newline at end of file |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | private function buildAssocations(): void |
| 53 | 53 | { |
| 54 | - array_walk_recursive($this->stubs, [$this, 'buildAssocationFromStub'] ); |
|
| 54 | + array_walk_recursive($this->stubs, [$this, 'buildAssocationFromStub']); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | private function getStubs(?string $baseType, ?string $targetType): array |
| 63 | 63 | { |
| 64 | - if($baseType === null || |
|
| 64 | + if ($baseType === null || |
|
| 65 | 65 | !array_key_exists($baseType, $this->stubs) || |
| 66 | - !array_key_exists($targetType, $this->stubs[$baseType])){ |
|
| 66 | + !array_key_exists($targetType, $this->stubs[$baseType])) { |
|
| 67 | 67 | return []; |
| 68 | 68 | } |
| 69 | 69 | return $this->stubs[$baseType][$targetType]; |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | $this->addAssocations($assocations); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - private function addAssocations(array $additionals){ |
|
| 89 | + private function addAssocations(array $additionals) { |
|
| 90 | 90 | $this->assocations = array_merge($this->assocations, $additionals); |
| 91 | 91 | } |
| 92 | 92 | |
@@ -103,15 +103,15 @@ discard block |
||
| 103 | 103 | $this->checkClassExists($className); |
| 104 | 104 | if (!array_key_exists($relName, $this->entities[$className]->getStubs())) { |
| 105 | 105 | $msg = 'Relation %s not registered on %s'; |
| 106 | - throw new \InvalidArgumentException(sprintf($msg,$relName,$className)); |
|
| 106 | + throw new \InvalidArgumentException(sprintf($msg, $relName, $className)); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - if(empty($this->assocations)) { |
|
| 109 | + if (empty($this->assocations)) { |
|
| 110 | 110 | $this->buildAssocations(); |
| 111 | 111 | } |
| 112 | 112 | $entites = $this->entities[$className]; |
| 113 | 113 | $relation = $entites->getStubs()[$relName]; |
| 114 | - return array_reduce($relation->getAssocations(), function($carry, Association $item) use ($relation){ |
|
| 114 | + return array_reduce($relation->getAssocations(), function ($carry, Association $item) use ($relation){ |
|
| 115 | 115 | $carry[] = ($item->getFirst() === $relation) ? $item->getLast() : $item->getFirst(); |
| 116 | 116 | return $carry; |
| 117 | 117 | },[]); |
@@ -125,11 +125,11 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | public function getRelationsByClass(string $className): array |
| 127 | 127 | { |
| 128 | - if(empty($this->assocations)){ |
|
| 128 | + if (empty($this->assocations)) { |
|
| 129 | 129 | $this->buildAssocations(); |
| 130 | 130 | } |
| 131 | 131 | $this->checkClassExists($className); |
| 132 | - return array_reduce($this->entities[$className]->getStubs(), function($carry, AssociationStubBase $item){ |
|
| 132 | + return array_reduce($this->entities[$className]->getStubs(), function ($carry, AssociationStubBase $item) { |
|
| 133 | 133 | return array_merge($carry, $item->getAssocations()); |
| 134 | 134 | },[]); |
| 135 | 135 | } |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | { |
| 142 | 142 | if (!$this->hasClass($className)) { |
| 143 | 143 | $msg = '%s does not exist in holder'; |
| 144 | - throw new \InvalidArgumentException(sprintf($msg,$className)); |
|
| 144 | + throw new \InvalidArgumentException(sprintf($msg, $className)); |
|
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | /** |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | public function getRelations(): array |
| 154 | 154 | { |
| 155 | - if(empty($this->assocations)) { |
|
| 155 | + if (empty($this->assocations)) { |
|
| 156 | 156 | $this->buildAssocations(); |
| 157 | 157 | } |
| 158 | 158 | return array_values($this->assocations); |
@@ -145,10 +145,10 @@ discard block |
||
| 145 | 145 | $stub->setRelationName($name); |
| 146 | 146 | $stub->setThroughFieldChain($keyChain); |
| 147 | 147 | $stub->setKeyFieldName($keyChain[0]); |
| 148 | - $stub->setForeignFieldName( $keyChain[4]); |
|
| 148 | + $stub->setForeignFieldName($keyChain[4]); |
|
| 149 | 149 | $stub->setMultiplicity(AssociationStubRelationType::MANY()); |
| 150 | 150 | $stub->setMorphType($keyChain[2]); |
| 151 | - $stub->setTargType( get_class($relation->getRelated())); |
|
| 151 | + $stub->setTargType(get_class($relation->getRelated())); |
|
| 152 | 152 | return $stub; |
| 153 | 153 | } |
| 154 | 154 | |
@@ -257,10 +257,10 @@ discard block |
||
| 257 | 257 | |
| 258 | 258 | private static $fieldOrderCache = [ |
| 259 | 259 | 'BelongsTo' => ['foreignKey', 'ownerKey'], |
| 260 | - 'BelongsToMany' => ['parentKey','foreignPivotKey','relatedPivotKey','relatedKey'], |
|
| 261 | - 'HasOneOrMany' => ['localKey', 'foreignKey' ], |
|
| 260 | + 'BelongsToMany' => ['parentKey', 'foreignPivotKey', 'relatedPivotKey', 'relatedKey'], |
|
| 261 | + 'HasOneOrMany' => ['localKey', 'foreignKey'], |
|
| 262 | 262 | 'HasManyThrough' => ['localKey', 'firstKey', 'secondLocalKey', 'secondKey'], |
| 263 | - 'MorphToMany' => ['parentKey','foreignPivotKey','morphType', 'relatedPivotKey','relatedKey'], |
|
| 263 | + 'MorphToMany' => ['parentKey', 'foreignPivotKey', 'morphType', 'relatedPivotKey', 'relatedKey'], |
|
| 264 | 264 | 'MorphTo' => ['foreignKey', 'morphType', 'ownerKey'], |
| 265 | 265 | 'MorphOneOrMany' => ['localKey', 'morphType', 'foreignKey'], |
| 266 | 266 | ]; |
@@ -44,11 +44,11 @@ |
||
| 44 | 44 | if ($thisNull == $thatNull && null === $thatTarg) { |
| 45 | 45 | return false; |
| 46 | 46 | } |
| 47 | - if((!$thisNull && |
|
| 47 | + if ((!$thisNull && |
|
| 48 | 48 | !$thatNull) && |
| 49 | 49 | ($this->getBaseType() !== $otherStub->getTargType() || |
| 50 | 50 | $otherStub->getBaseType() !== $this->getTargType()) |
| 51 | - ){ |
|
| 51 | + ) { |
|
| 52 | 52 | return false; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | $first = -1 === $stubOne->compare($stubTwo); |
| 23 | 23 | |
| 24 | 24 | $association = new AssociationMonomorphic(); |
| 25 | - if($stubOne->getTargType() == null && self::$marshalPolymorphics){ |
|
| 25 | + if ($stubOne->getTargType() == null && self::$marshalPolymorphics) { |
|
| 26 | 26 | $stubOne->addAssociation($association); |
| 27 | 27 | $stubOne = self::marshalPolyToMono($stubOne, $stubTwo); |
| 28 | 28 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | private static function marshalPolyToMono(AssociationStubBase $stub, AssociationStubBase $stubTwo): AssociationStubBase{ |
| 37 | 37 | $stubNew = clone $stub; |
| 38 | 38 | $relPolyTypeName = substr($stubTwo->getBaseType(), strrpos($stubTwo->getBaseType(), '\\')+1); |
| 39 | - $relPolyTypeName = Str::plural($relPolyTypeName, 1); |
|
| 39 | + $relPolyTypeName = Str::plural($relPolyTypeName, 1); |
|
| 40 | 40 | $stubNew->setRelationName($stub->getRelationName() . '_' . $relPolyTypeName); |
| 41 | 41 | $stubNew->setTargType($stubTwo->getBaseType()); |
| 42 | 42 | $stubNew->setForeignFieldName($stubTwo->getKeyFieldName()); |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | private static function checkAssocations(AssociationStubBase $stubOne, AssociationStubBase $stubTwo): ?Association{ |
| 52 | 52 | $assocOne = $stubOne->getAssocations(); |
| 53 | - foreach($assocOne as $association){ |
|
| 53 | + foreach ($assocOne as $association) { |
|
| 54 | 54 | $isFirst = $association->getFirst() === $stubOne; |
| 55 | - if($association->{$isFirst ? 'getLast' : 'getFirst'}() == $stubTwo){ |
|
| 55 | + if ($association->{$isFirst ? 'getLast' : 'getFirst'}() == $stubTwo) { |
|
| 56 | 56 | return $association; |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - if(null === $this->throughFieldChain){ |
|
| 205 | + if (null === $this->throughFieldChain) { |
|
| 206 | 206 | return false; |
| 207 | 207 | } |
| 208 | 208 | return (null === $targType) === (null === $foreignField); |
@@ -282,10 +282,10 @@ discard block |
||
| 282 | 282 | { |
| 283 | 283 | $thisFirst = $this->getKeyFieldName() === '' ? false : $this->getKeyField()->getIsKeyField(); |
| 284 | 284 | $otherFirst = $other->getKeyFieldName() === '' ? false : $other->getKeyField()->getIsKeyField(); |
| 285 | - if( |
|
| 285 | + if ( |
|
| 286 | 286 | ($thisFirst || $otherFirst) && |
| 287 | 287 | !($thisFirst && $otherFirst) |
| 288 | - ){ |
|
| 288 | + ) { |
|
| 289 | 289 | return $thisFirst ? -1 : 1; |
| 290 | 290 | } |
| 291 | 291 | $thisClass = get_class($this); |