@@ -56,7 +56,7 @@ |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | $constructor = $this->class->addMethod('__construct') |
59 | - ->setBody('parent::__construct($attributes, $state);'); |
|
59 | + ->setBody('parent::__construct($attributes, $state);'); |
|
60 | 60 | $constructor->addParameter('attributes') |
61 | 61 | ->setType('array') |
62 | 62 | ->setDefaultValue([]); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $name = $this->relation->getName(); |
51 | 51 | $foreignMapper = $mapper->getOrm()->getMapper($this->relation->getForeignMapper()); |
52 | 52 | $type = $foreignMapper->getEntityNamespace() |
53 | - . '\\' . $foreignMapper->getEntityClass(); |
|
53 | + . '\\' . $foreignMapper->getEntityClass(); |
|
54 | 54 | |
55 | 55 | $class->getNamespace()->addUse($type, null, $type); |
56 | 56 | |
@@ -70,15 +70,15 @@ discard block |
||
70 | 70 | $setter = $class->addMethod(Str::methodName($name, 'set')); |
71 | 71 | $setter->setVisibility(ClassType::VISIBILITY_PUBLIC); |
72 | 72 | $setter->addParameter('value') |
73 | - ->setType($type) |
|
74 | - ->setNullable(true); |
|
73 | + ->setType($type) |
|
74 | + ->setNullable(true); |
|
75 | 75 | $setter->addBody('$this->set(\'' . $name . '\', $value);'); |
76 | 76 | |
77 | 77 | $getter = $class->addMethod(Str::methodName($name, 'get')); |
78 | 78 | $getter->setVisibility(ClassType::VISIBILITY_PUBLIC); |
79 | 79 | $getter->addBody('return $this->get(\'' . $name . '\');'); |
80 | 80 | $getter->setReturnType($type) |
81 | - ->setReturnNullable(true); |
|
81 | + ->setReturnNullable(true); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | return $class; |
@@ -21,7 +21,7 @@ |
||
21 | 21 | |
22 | 22 | public function with(Relation $relation) |
23 | 23 | { |
24 | - $clone = clone($this); |
|
24 | + $clone = clone($this); |
|
25 | 25 | $clone->relation = $relation; |
26 | 26 | |
27 | 27 | return $clone; |
@@ -78,14 +78,14 @@ |
||
78 | 78 | $setter->setVisibility(ClassType::VISIBILITY_PUBLIC); |
79 | 79 | $setter->addParameter('value') |
80 | 80 | ->setType($type) |
81 | - ->setNullable($this->attributeIsNullable()); |
|
81 | + ->setNullable($this->attributeIsNullable()); |
|
82 | 82 | $setter->addBody('$this->set(\'' . $name . '\', $value);'); |
83 | 83 | |
84 | 84 | $getter = $class->addMethod(Str::methodName($name, 'get')); |
85 | 85 | $getter->setVisibility(ClassType::VISIBILITY_PUBLIC); |
86 | 86 | $getter->addBody('return $this->get(\'' . $name . '\');'); |
87 | 87 | $getter->setReturnType($type) |
88 | - ->setReturnNullable($this->attributeIsNullable()); |
|
88 | + ->setReturnNullable($this->attributeIsNullable()); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | return $class; |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $class->getNamespace()->addUse(\Sirius\Orm\Action\Delete::class, 'DeleteAction'); |
52 | 52 | $class->getNamespace()->addUse(\Sirius\Orm\Action\Update::class, 'UpdateAction'); |
53 | 53 | $class->addProperty('deletedAtColumn', $this->behaviour->getDeletedAtColumn()) |
54 | - ->setVisibility('protected'); |
|
54 | + ->setVisibility('protected'); |
|
55 | 55 | |
56 | 56 | // |
57 | 57 | $method = $class->addMethod('newDeleteAction'); |
@@ -116,21 +116,21 @@ discard block |
||
116 | 116 | public function observeBaseQueryClass(ClassType $class): ClassType |
117 | 117 | { |
118 | 118 | $class->addProperty('deletedAtColumn', $this->behaviour->getDeletedAtColumn()) |
119 | - ->setVisibility('protected'); |
|
119 | + ->setVisibility('protected'); |
|
120 | 120 | |
121 | 121 | // add guard |
122 | 122 | if ( ! $class->hasMethod('init')) { |
123 | 123 | $class->addMethod('init') |
124 | - ->setVisibility(ClassType::VISIBILITY_PROTECTED) |
|
125 | - ->setBody('parent::init();' . PHP_EOL); |
|
124 | + ->setVisibility(ClassType::VISIBILITY_PROTECTED) |
|
125 | + ->setBody('parent::init();' . PHP_EOL); |
|
126 | 126 | } |
127 | 127 | $init = $class->getMethod('init'); |
128 | 128 | $init->addBody('$this->guards[] = $this->deletedAtColumn . \' IS NULL\';' . PHP_EOL); |
129 | 129 | |
130 | 130 | // add withTrashed() |
131 | 131 | $class->addMethod('withTrashed') |
132 | - ->setVisibility(ClassType::VISIBILITY_PUBLIC) |
|
133 | - ->setBody(' |
|
132 | + ->setVisibility(ClassType::VISIBILITY_PUBLIC) |
|
133 | + ->setBody(' |
|
134 | 134 | $guards = []; |
135 | 135 | foreach ($this->guards as $k => $v) { |
136 | 136 | if ($v != $this->deletedAtColumn . \' IS NULL\') { |
@@ -119,7 +119,7 @@ |
||
119 | 119 | ->setVisibility('protected'); |
120 | 120 | |
121 | 121 | // add guard |
122 | - if ( ! $class->hasMethod('init')) { |
|
122 | + if (!$class->hasMethod('init')) { |
|
123 | 123 | $class->addMethod('init') |
124 | 124 | ->setVisibility(ClassType::VISIBILITY_PROTECTED) |
125 | 125 | ->setBody('parent::init();' . PHP_EOL); |
@@ -45,13 +45,13 @@ discard block |
||
45 | 45 | public function observeBaseMapperClass(ClassType $class): ClassType |
46 | 46 | { |
47 | 47 | $class->addProperty('createdAtColumn', $this->behaviour->getCreatedAtColumn()) |
48 | - ->setVisibility('protected'); |
|
48 | + ->setVisibility('protected'); |
|
49 | 49 | $class->addProperty('updatedAtColumn', $this->behaviour->getUpdatedAtColumn()) |
50 | - ->setVisibility('protected'); |
|
50 | + ->setVisibility('protected'); |
|
51 | 51 | |
52 | 52 | if ( ! $class->hasMethod('init')) { |
53 | 53 | $class->addMethod('init')->setVisibility('public') |
54 | - ->setBody('parent::init();' . PHP_EOL); |
|
54 | + ->setBody('parent::init();' . PHP_EOL); |
|
55 | 55 | } |
56 | 56 | $class->getNamespace()->addUse(\Sirius\Orm\Behaviour\Timestamps::class); |
57 | 57 | $method = $class->getMethod('init'); |
@@ -64,35 +64,35 @@ discard block |
||
64 | 64 | public function observeBaseQueryClass(ClassType $class): ClassType |
65 | 65 | { |
66 | 66 | $class->addProperty('createdAtColumn', $this->behaviour->getCreatedAtColumn()) |
67 | - ->setVisibility('protected'); |
|
67 | + ->setVisibility('protected'); |
|
68 | 68 | $class->addProperty('updatedAtColumn', $this->behaviour->getUpdatedAtColumn()) |
69 | - ->setVisibility('protected'); |
|
69 | + ->setVisibility('protected'); |
|
70 | 70 | |
71 | 71 | // add methods |
72 | 72 | $class->addMethod('orderByFirstCreated') |
73 | - ->setVisibility('public') |
|
74 | - ->setBody(' |
|
73 | + ->setVisibility('public') |
|
74 | + ->setBody(' |
|
75 | 75 | $this->orderBy($this->createdAtColumn . \' ASC\'); |
76 | 76 | |
77 | 77 | return $this; |
78 | 78 | '); |
79 | 79 | $class->addMethod('orderByLastCreated') |
80 | - ->setVisibility('public') |
|
81 | - ->setBody(' |
|
80 | + ->setVisibility('public') |
|
81 | + ->setBody(' |
|
82 | 82 | $this->orderBy($this->createdAtColumn . \' DESC\'); |
83 | 83 | |
84 | 84 | return $this; |
85 | 85 | '); |
86 | 86 | $class->addMethod('orderByFirstUpdated') |
87 | - ->setVisibility('public') |
|
88 | - ->setBody(' |
|
87 | + ->setVisibility('public') |
|
88 | + ->setBody(' |
|
89 | 89 | $this->orderBy($this->updatedAtColumn . \' ASC\'); |
90 | 90 | |
91 | 91 | return $this; |
92 | 92 | '); |
93 | 93 | $class->addMethod('orderByLastCreated') |
94 | - ->setVisibility('public') |
|
95 | - ->setBody(' |
|
94 | + ->setVisibility('public') |
|
95 | + ->setBody(' |
|
96 | 96 | $this->orderBy($this->updatedAtColumn . \' DESC\'); |
97 | 97 | |
98 | 98 | return $this; |
@@ -49,7 +49,7 @@ |
||
49 | 49 | $class->addProperty('updatedAtColumn', $this->behaviour->getUpdatedAtColumn()) |
50 | 50 | ->setVisibility('protected'); |
51 | 51 | |
52 | - if ( ! $class->hasMethod('init')) { |
|
52 | + if (!$class->hasMethod('init')) { |
|
53 | 53 | $class->addMethod('init')->setVisibility('public') |
54 | 54 | ->setBody('parent::init();' . PHP_EOL); |
55 | 55 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | unset($this->lazyMappers[$name]); |
106 | 106 | } |
107 | 107 | |
108 | - if ( ! isset($this->mappers[$name]) || ! $this->mappers[$name]) { |
|
108 | + if (!isset($this->mappers[$name]) || !$this->mappers[$name]) { |
|
109 | 109 | throw new InvalidArgumentException(sprintf('Mapper named %s is not registered', $name)); |
110 | 110 | } |
111 | 111 | |
@@ -138,14 +138,14 @@ discard block |
||
138 | 138 | { |
139 | 139 | $foreignMapper = $options[RelationConfig::FOREIGN_MAPPER]; |
140 | 140 | if ($this->has($foreignMapper)) { |
141 | - if ( ! $foreignMapper instanceof Mapper) { |
|
141 | + if (!$foreignMapper instanceof Mapper) { |
|
142 | 142 | $foreignMapper = $this->get($foreignMapper); |
143 | 143 | } |
144 | 144 | } |
145 | 145 | $type = $options[RelationConfig::TYPE]; |
146 | 146 | $relationClass = 'Sirius\\Orm\\Relation\\' . Str::className($type); |
147 | 147 | |
148 | - if ( ! class_exists($relationClass)) { |
|
148 | + if (!class_exists($relationClass)) { |
|
149 | 149 | throw new InvalidArgumentException("{$relationClass} does not exist"); |
150 | 150 | } |
151 | 151 | |
@@ -172,13 +172,13 @@ discard block |
||
172 | 172 | $mapper = $this->mapperLocator->get($mapperConfigOrFactory); |
173 | 173 | } |
174 | 174 | |
175 | - if (! $mapper) { |
|
175 | + if (!$mapper) { |
|
176 | 176 | throw new InvalidArgumentException( |
177 | 177 | 'The mapper could not be generated/retrieved.' |
178 | 178 | ); |
179 | 179 | } |
180 | 180 | |
181 | - if (! $mapper instanceof Mapper) { |
|
181 | + if (!$mapper instanceof Mapper) { |
|
182 | 182 | throw new InvalidArgumentException( |
183 | 183 | 'The mapper generated from the factory is not a valid `Mapper` instance.' |
184 | 184 | ); |
@@ -25,10 +25,10 @@ discard block |
||
25 | 25 | |
26 | 26 | protected function addActionOnDelete(BaseAction $action) |
27 | 27 | { |
28 | - $relations = $action->getOption('relations'); |
|
28 | + $relations = $action->getOption('relations'); |
|
29 | 29 | |
30 | 30 | // no cascade delete? treat it as a save |
31 | - if ( ! $this->isCascade()) { |
|
31 | + if (!$this->isCascade()) { |
|
32 | 32 | $this->addActionOnSave($action); |
33 | 33 | } elseif ($relations === true || in_array($this->name, (array)$relations)) { |
34 | 34 | $nativeEntity = $action->getEntity(); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | ->first(); |
41 | 41 | |
42 | 42 | if ($foreignEntity) { |
43 | - $deleteAction = $this->foreignMapper |
|
43 | + $deleteAction = $this->foreignMapper |
|
44 | 44 | ->newDeleteAction($foreignEntity, ['relations' => $remainingRelations]); |
45 | 45 | $action->prepend($deleteAction); |
46 | 46 | $action->append($this->newSyncAction($action->getEntity(), $foreignEntity, 'delete')); |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | |
51 | 51 | protected function addActionOnSave(BaseAction $action) |
52 | 52 | { |
53 | - if ( ! $this->relationWasChanged($action->getEntity())) { |
|
53 | + if (!$this->relationWasChanged($action->getEntity())) { |
|
54 | 54 | return; |
55 | 55 | } |
56 | 56 | |
57 | - if ( ! $action->includesRelation($this->name)) { |
|
57 | + if (!$action->includesRelation($this->name)) { |
|
58 | 58 | return; |
59 | 59 | } |
60 | 60 |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | public function includesRelation($relationName) { |
118 | - $relations = (array) $this->getOption('relations'); |
|
118 | + $relations = (array)$this->getOption('relations'); |
|
119 | 119 | |
120 | 120 | return $relations === true || in_array($relationName, $relations); |
121 | 121 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | protected function addActionsForRelatedEntities() |
128 | 128 | { |
129 | - if (! $this->mapper) { |
|
129 | + if (!$this->mapper) { |
|
130 | 130 | return; |
131 | 131 | } |
132 | 132 |
@@ -45,7 +45,7 @@ |
||
45 | 45 | $mapper->getHydrator()->set($action->getEntity(), $this->updateColumn, $now); |
46 | 46 | } |
47 | 47 | if ($action instanceof Update && $this->updateColumn) { |
48 | - if ( ! empty($action->getEntity()->getChanges())) { |
|
48 | + if (!empty($action->getEntity()->getChanges())) { |
|
49 | 49 | $action->addColumns([$this->updateColumn => $now]); |
50 | 50 | $mapper->getHydrator()->set($action->getEntity(), $this->updateColumn, $now); |
51 | 51 | } |