@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | return [ |
75 | 75 | 'path' => $mapper->getDestination() . $class->getName() . '.php', |
76 | 76 | 'contents' => $this->classPrinter->printFile($file) |
77 | - . PHP_EOL |
|
78 | - . $namespace |
|
79 | - . $this->classPrinter->printClass($class) |
|
77 | + . PHP_EOL |
|
78 | + . $namespace |
|
79 | + . $this->classPrinter->printClass($class) |
|
80 | 80 | ]; |
81 | 81 | } |
82 | 82 | |
@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | return [ |
97 | 97 | 'path' => $mapper->getDestination() . $class->getName() . '.php', |
98 | 98 | 'contents' => $this->classPrinter->printFile($file) |
99 | - . PHP_EOL |
|
100 | - . $namespace |
|
101 | - . $this->classPrinter->printClass($class) |
|
99 | + . PHP_EOL |
|
100 | + . $namespace |
|
101 | + . $this->classPrinter->printClass($class) |
|
102 | 102 | ]; |
103 | 103 | } |
104 | 104 | |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | return [ |
114 | 114 | 'path' => $mapper->getDestination() . $class->getName() . '.php', |
115 | 115 | 'contents' => $this->classPrinter->printFile($file) |
116 | - . PHP_EOL |
|
117 | - . $namespace |
|
118 | - . $this->classPrinter->printClass($class) |
|
116 | + . PHP_EOL |
|
117 | + . $namespace |
|
118 | + . $this->classPrinter->printClass($class) |
|
119 | 119 | ]; |
120 | 120 | } |
121 | 121 | |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | return [ |
138 | 138 | 'path' => $mapper->getDestination() . $class->getName() . '.php', |
139 | 139 | 'contents' => $this->classPrinter->printFile($file) |
140 | - . PHP_EOL |
|
141 | - . $namespace |
|
142 | - . $this->classPrinter->printClass($class) |
|
140 | + . PHP_EOL |
|
141 | + . $namespace |
|
142 | + . $this->classPrinter->printClass($class) |
|
143 | 143 | ]; |
144 | 144 | } |
145 | 145 | |
@@ -155,9 +155,9 @@ discard block |
||
155 | 155 | return [ |
156 | 156 | 'path' => $mapper->getEntityDestination() . $class->getName() . '.php', |
157 | 157 | 'contents' => $this->classPrinter->printFile($file) |
158 | - . PHP_EOL |
|
159 | - . $namespace |
|
160 | - . $this->classPrinter->printClass($class) |
|
158 | + . PHP_EOL |
|
159 | + . $namespace |
|
160 | + . $this->classPrinter->printClass($class) |
|
161 | 161 | ]; |
162 | 162 | } |
163 | 163 | |
@@ -179,9 +179,9 @@ discard block |
||
179 | 179 | return [ |
180 | 180 | 'path' => $mapper->getEntityDestination() . $class->getName() . '.php', |
181 | 181 | 'contents' => $this->classPrinter->printFile($file) |
182 | - . PHP_EOL |
|
183 | - . $namespace |
|
184 | - . $this->classPrinter->printClass($class) |
|
182 | + . PHP_EOL |
|
183 | + . $namespace |
|
184 | + . $this->classPrinter->printClass($class) |
|
185 | 185 | ]; |
186 | 186 | } |
187 | 187 | } |
@@ -145,8 +145,8 @@ discard block |
||
145 | 145 | { |
146 | 146 | $this->namespace->addUse($this->mapper->getEntityNamespace() . '\\' . $this->mapper->getEntityClass()); |
147 | 147 | $method = $this->class->addMethod('find') |
148 | - ->setReturnNullable(true) |
|
149 | - ->setReturnType($this->mapper->getEntityClass()); |
|
148 | + ->setReturnNullable(true) |
|
149 | + ->setReturnType($this->mapper->getEntityClass()); |
|
150 | 150 | $method->addParameter('pk'); |
151 | 151 | $method->addParameter('load', [])->setType('array'); |
152 | 152 | $method->setBody('return $this->newQuery()->find($pk, $load);'); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | protected function addNewQueryMethod() |
156 | 156 | { |
157 | 157 | $method = $this->class->addMethod('newQuery') |
158 | - ->setReturnType($this->mapper->getQueryClass()); |
|
158 | + ->setReturnType($this->mapper->getQueryClass()); |
|
159 | 159 | $method->addBody(sprintf('$query = new %s($this->getReadConnection(), $this);', $this->mapper->getQueryClass())); |
160 | 160 | $method->addBody('return $this->behaviours->apply($this, __FUNCTION__, $query);'); |
161 | 161 | } |
@@ -163,17 +163,17 @@ discard block |
||
163 | 163 | protected function addNewSubselectQueryMethod() |
164 | 164 | { |
165 | 165 | $method = $this->class->addMethod('newSubselectQuery') |
166 | - ->setReturnType($this->mapper->getQueryClass()); |
|
166 | + ->setReturnType($this->mapper->getQueryClass()); |
|
167 | 167 | /** @scrutinizer ignore-deprecated */ $this->class->getNamespace()->addUse(Connection::class, null, $connectionAlias); |
168 | 168 | $method->addParameter('connection') |
169 | - ->setType($connectionAlias); |
|
169 | + ->setType($connectionAlias); |
|
170 | 170 | |
171 | 171 | /** @scrutinizer ignore-deprecated */ $this->class->getNamespace()->addUse(Bindings::class, null, $bindingsAlias); |
172 | 172 | $method->addParameter('bindings') |
173 | - ->setType($bindingsAlias); |
|
173 | + ->setType($bindingsAlias); |
|
174 | 174 | |
175 | 175 | $method->addParameter('indent') |
176 | - ->setType('string'); |
|
176 | + ->setType('string'); |
|
177 | 177 | |
178 | 178 | $method->addBody(sprintf('$query = new %s($this->getReadConnection(), $this, $bindings, $indent);', $this->mapper->getQueryClass())); |
179 | 179 | $method->addBody('return $this->behaviours->apply($this, __FUNCTION__, $query);'); |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $this->namespace->addUse(StateEnum::class); |
187 | 187 | |
188 | 188 | $method = $this->class->addMethod('save') |
189 | - ->setReturnType('bool'); |
|
189 | + ->setReturnType('bool'); |
|
190 | 190 | $method->addParameter('entity')->setType($this->mapper->getEntityClass()); |
191 | 191 | $method->addParameter('withRelations', false); |
192 | 192 | $method->setBody(' |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | protected function addDeleteMethod() |
225 | 225 | { |
226 | 226 | $method = $this->class->addMethod('delete') |
227 | - ->setReturnType('bool'); |
|
227 | + ->setReturnType('bool'); |
|
228 | 228 | $method->addParameter('entity')->setType($this->mapper->getEntityClass()); |
229 | 229 | $method->addParameter('withRelations', false); |
230 | 230 | $method->setBody(' |
@@ -47,13 +47,13 @@ discard block |
||
47 | 47 | public function observeBaseMapperClass(ClassType $class): ClassType |
48 | 48 | { |
49 | 49 | $class->addProperty('createdAtColumn', $this->behaviour->getCreatedAtColumn()) |
50 | - ->setVisibility('protected'); |
|
50 | + ->setVisibility('protected'); |
|
51 | 51 | $class->addProperty('updatedAtColumn', $this->behaviour->getUpdatedAtColumn()) |
52 | - ->setVisibility('protected'); |
|
52 | + ->setVisibility('protected'); |
|
53 | 53 | |
54 | 54 | if (! $class->hasMethod('init')) { |
55 | 55 | $class->addMethod('init')->setVisibility('public') |
56 | - ->setBody('parent::init();' . PHP_EOL); |
|
56 | + ->setBody('parent::init();' . PHP_EOL); |
|
57 | 57 | } |
58 | 58 | /** @scrutinizer ignore-deprecated */ $class->getNamespace()->addUse(\Sirius\Orm\Behaviour\Timestamps::class); |
59 | 59 | $method = $class->getMethod('init'); |
@@ -66,35 +66,35 @@ discard block |
||
66 | 66 | public function observeBaseQueryClass(ClassType $class): ClassType |
67 | 67 | { |
68 | 68 | $class->addProperty('createdAtColumn', $this->behaviour->getCreatedAtColumn()) |
69 | - ->setVisibility('protected'); |
|
69 | + ->setVisibility('protected'); |
|
70 | 70 | $class->addProperty('updatedAtColumn', $this->behaviour->getUpdatedAtColumn()) |
71 | - ->setVisibility('protected'); |
|
71 | + ->setVisibility('protected'); |
|
72 | 72 | |
73 | 73 | // add methods |
74 | 74 | $class->addMethod('orderByFirstCreated') |
75 | - ->setVisibility('public') |
|
76 | - ->setBody(' |
|
75 | + ->setVisibility('public') |
|
76 | + ->setBody(' |
|
77 | 77 | $this->orderBy($this->createdAtColumn . \' ASC\'); |
78 | 78 | |
79 | 79 | return $this; |
80 | 80 | '); |
81 | 81 | $class->addMethod('orderByLastCreated') |
82 | - ->setVisibility('public') |
|
83 | - ->setBody(' |
|
82 | + ->setVisibility('public') |
|
83 | + ->setBody(' |
|
84 | 84 | $this->orderBy($this->createdAtColumn . \' DESC\'); |
85 | 85 | |
86 | 86 | return $this; |
87 | 87 | '); |
88 | 88 | $class->addMethod('orderByFirstUpdated') |
89 | - ->setVisibility('public') |
|
90 | - ->setBody(' |
|
89 | + ->setVisibility('public') |
|
90 | + ->setBody(' |
|
91 | 91 | $this->orderBy($this->updatedAtColumn . \' ASC\'); |
92 | 92 | |
93 | 93 | return $this; |
94 | 94 | '); |
95 | 95 | $class->addMethod('orderByLastCreated') |
96 | - ->setVisibility('public') |
|
97 | - ->setBody(' |
|
96 | + ->setVisibility('public') |
|
97 | + ->setBody(' |
|
98 | 98 | $this->orderBy($this->updatedAtColumn . \' DESC\'); |
99 | 99 | |
100 | 100 | return $this; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | /** @scrutinizer ignore-deprecated */ $class->getNamespace()->addUse(\Sirius\Orm\Action\Delete::class, 'DeleteAction'); |
55 | 55 | /** @scrutinizer ignore-deprecated */ $class->getNamespace()->addUse(\Sirius\Orm\Action\Update::class, 'UpdateAction'); |
56 | 56 | $class->addProperty('deletedAtColumn', $this->behaviour->getDeletedAtColumn()) |
57 | - ->setVisibility('protected'); |
|
57 | + ->setVisibility('protected'); |
|
58 | 58 | |
59 | 59 | // |
60 | 60 | $method = $class->addMethod('newDeleteAction'); |
@@ -119,13 +119,13 @@ discard block |
||
119 | 119 | public function observeBaseQueryClass(ClassType $class): ClassType |
120 | 120 | { |
121 | 121 | $class->addProperty('deletedAtColumn', $this->behaviour->getDeletedAtColumn()) |
122 | - ->setVisibility('protected'); |
|
122 | + ->setVisibility('protected'); |
|
123 | 123 | |
124 | 124 | // add guard |
125 | 125 | if (! $class->hasMethod('init')) { |
126 | 126 | $class->addMethod('init') |
127 | - ->setVisibility(ClassType::VISIBILITY_PROTECTED) |
|
128 | - ->setBody('parent::init();' . PHP_EOL); |
|
127 | + ->setVisibility(ClassType::VISIBILITY_PROTECTED) |
|
128 | + ->setBody('parent::init();' . PHP_EOL); |
|
129 | 129 | } |
130 | 130 | $init = $class->getMethod('init'); |
131 | 131 | $init->addBody('$this->withoutTrashed();' . PHP_EOL); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $name = $this->relation->getName(); |
53 | 53 | $foreignMapper = $mapper->getOrm()->getMapper($this->relation->getForeignMapper()); |
54 | 54 | $type = $foreignMapper->getEntityNamespace() |
55 | - . '\\' . $foreignMapper->getEntityClass(); |
|
55 | + . '\\' . $foreignMapper->getEntityClass(); |
|
56 | 56 | |
57 | 57 | /** @scrutinizer ignore-deprecated */ $class->getNamespace()->addUse($type, null, $type); |
58 | 58 | |
@@ -72,15 +72,15 @@ discard block |
||
72 | 72 | $setter = $class->addMethod(Str::methodName($name, 'set')); |
73 | 73 | $setter->setVisibility(ClassType::VISIBILITY_PUBLIC); |
74 | 74 | $setter->addParameter('value') |
75 | - ->setType($type) |
|
76 | - ->setNullable(true); |
|
75 | + ->setType($type) |
|
76 | + ->setNullable(true); |
|
77 | 77 | $setter->addBody('$this->set(\'' . $name . '\', $value);'); |
78 | 78 | |
79 | 79 | $getter = $class->addMethod(Str::methodName($name, 'get')); |
80 | 80 | $getter->setVisibility(ClassType::VISIBILITY_PUBLIC); |
81 | 81 | $getter->addBody('return $this->get(\'' . $name . '\');'); |
82 | 82 | $getter->setReturnType($type) |
83 | - ->setReturnNullable(true); |
|
83 | + ->setReturnNullable(true); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | return $class; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $name = $this->relation->getName(); |
56 | 56 | $foreignMapper = $mapper->getOrm()->getMapper($this->relation->getForeignMapper()); |
57 | 57 | $type = $foreignMapper->getEntityNamespace() |
58 | - . '\\' . $foreignMapper->getEntityClass(); |
|
58 | + . '\\' . $foreignMapper->getEntityClass(); |
|
59 | 59 | |
60 | 60 | /** @scrutinizer ignore-deprecated */ $class->getNamespace()->addUse(Collection::class); |
61 | 61 | /** @scrutinizer ignore-deprecated */ $class->getNamespace()->addUse($type, null, $type); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $setter = $class->addMethod(Str::methodName($name, 'set')); |
67 | 67 | $setter->setVisibility(ClassType::VISIBILITY_PUBLIC); |
68 | 68 | $setter->addParameter('value') |
69 | - ->setType('Collection'); |
|
69 | + ->setType('Collection'); |
|
70 | 70 | $setter->setBody('$this->set(\'' . $name . '\', $value);'); |
71 | 71 | |
72 | 72 | $getter = $class->addMethod(Str::methodName($name, 'get')); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $adder = $class->addMethod(Str::methodName($singular, 'add')); |
81 | 81 | $adder->setVisibility(ClassType::VISIBILITY_PUBLIC); |
82 | 82 | $adder->addParameter($singular) |
83 | - ->setType($type); |
|
83 | + ->setType($type); |
|
84 | 84 | $adder->setBody(sprintf('$this->get(\'%s\')->add($%s);', $name, $singular)); |
85 | 85 | |
86 | 86 | $class = $this->addAggregates($class); |