@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Chubbyphp\Model; |
6 | 6 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Chubbyphp\Model; |
6 | 6 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Chubbyphp\Model; |
6 | 6 | |
@@ -14,25 +14,25 @@ discard block |
||
14 | 14 | */ |
15 | 15 | private function sort(string $modelClass, array $models, array $orderBy = null): array |
16 | 16 | { |
17 | - if ([] === $models) { |
|
18 | - return []; |
|
17 | + if ([ ] === $models) { |
|
18 | + return [ ]; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | if (null === $orderBy) { |
22 | 22 | return $models; |
23 | 23 | } |
24 | 24 | |
25 | - $reflections = []; |
|
25 | + $reflections = [ ]; |
|
26 | 26 | foreach ($orderBy as $property => $sortingDirection) { |
27 | 27 | $reflection = new \ReflectionProperty($modelClass, $property); |
28 | 28 | $reflection->setAccessible(true); |
29 | 29 | |
30 | - $reflections[$property] = $reflection; |
|
30 | + $reflections[ $property ] = $reflection; |
|
31 | 31 | } |
32 | 32 | |
33 | - usort($models, function (ModelInterface $a, ModelInterface $b) use ($reflections, $orderBy) { |
|
33 | + usort($models, function(ModelInterface $a, ModelInterface $b) use ($reflections, $orderBy) { |
|
34 | 34 | foreach ($orderBy as $property => $sortingDirection) { |
35 | - $reflection = $reflections[$property]; |
|
35 | + $reflection = $reflections[ $property ]; |
|
36 | 36 | $sorting = strcmp($reflection->getValue($a), $reflection->getValue($b)); |
37 | 37 | if ($sortingDirection === 'DESC') { |
38 | 38 | $sorting = $sorting * -1; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Chubbyphp\Model; |
6 | 6 | |
@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | /** |
10 | 10 | * @var ModelInterface[]|array |
11 | 11 | */ |
12 | - private $toPersistModels = []; |
|
12 | + private $toPersistModels = [ ]; |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * @var ModelInterface[]|array |
16 | 16 | */ |
17 | - private $toRemoveModels = []; |
|
17 | + private $toRemoveModels = [ ]; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * @param ModelInterface[]|array $models |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function addToPersistModel(ModelInterface $model): RelatedModelManipulationStack |
37 | 37 | { |
38 | - $this->toPersistModels[$model->getId()] = $model; |
|
38 | + $this->toPersistModels[ $model->getId() ] = $model; |
|
39 | 39 | |
40 | 40 | return $this; |
41 | 41 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function addToRemoveModel(ModelInterface $model): RelatedModelManipulationStack |
61 | 61 | { |
62 | - $this->toRemoveModels[$model->getId()] = $model; |
|
62 | + $this->toRemoveModels[ $model->getId() ] = $model; |
|
63 | 63 | |
64 | 64 | return $this; |
65 | 65 | } |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | { |
80 | 80 | $toRemoveModels = $this->toRemoveModels; |
81 | 81 | foreach ($toRemoveModels as $toRemoveModel) { |
82 | - if (isset($this->toPersistModels[$toRemoveModel->getId()])) { |
|
83 | - unset($toRemoveModels[$toRemoveModel->getId()]); |
|
82 | + if (isset($this->toPersistModels[ $toRemoveModel->getId() ])) { |
|
83 | + unset($toRemoveModels[ $toRemoveModel->getId() ]); |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Chubbyphp\Model; |
6 | 6 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Chubbyphp\Model\Collection; |
6 | 6 | |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | |
90 | 90 | $this->resolved = true; |
91 | 91 | |
92 | - $criteria = [$this->foreignField => $this->foreignId]; |
|
92 | + $criteria = [ $this->foreignField => $this->foreignId ]; |
|
93 | 93 | |
94 | - $models = []; |
|
94 | + $models = [ ]; |
|
95 | 95 | foreach ($this->resolver->findBy($this->modelClass, $criteria, $this->orderBy) as $model) { |
96 | - $models[$model->getId()] = $model; |
|
96 | + $models[ $model->getId() ] = $model; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | $this->initialModels = $models; |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | |
112 | 112 | $this->propertyReflection->setValue($model, $this->foreignId); |
113 | 113 | |
114 | - $this->models[$model->getId()] = $model; |
|
114 | + $this->models[ $model->getId() ] = $model; |
|
115 | 115 | |
116 | 116 | return $this; |
117 | 117 | } |
@@ -125,10 +125,10 @@ discard block |
||
125 | 125 | { |
126 | 126 | $this->resolveModels(); |
127 | 127 | |
128 | - if (isset($this->models[$model->getId()])) { |
|
128 | + if (isset($this->models[ $model->getId() ])) { |
|
129 | 129 | $this->propertyReflection->setValue($model, null); |
130 | 130 | |
131 | - unset($this->models[$model->getId()]); |
|
131 | + unset($this->models[ $model->getId() ]); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | return $this; |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | { |
144 | 144 | $this->resolveModels(); |
145 | 145 | |
146 | - $this->models = []; |
|
146 | + $this->models = [ ]; |
|
147 | 147 | foreach ($models as $model) { |
148 | 148 | $this->addModel($model); |
149 | 149 | } |
@@ -188,9 +188,9 @@ discard block |
||
188 | 188 | { |
189 | 189 | $this->resolveModels(); |
190 | 190 | |
191 | - $serializedModels = []; |
|
191 | + $serializedModels = [ ]; |
|
192 | 192 | foreach ($this->getModels() as $model) { |
193 | - $serializedModels[] = $model->jsonSerialize(); |
|
193 | + $serializedModels[ ] = $model->jsonSerialize(); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | return $serializedModels; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Chubbyphp\Model\Collection; |
6 | 6 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $this->foreignId = $foreignId; |
59 | 59 | $this->orderBy = $orderBy; |
60 | 60 | |
61 | - $this->models = []; |
|
61 | + $this->models = [ ]; |
|
62 | 62 | |
63 | 63 | $this->propertyReflection = new \ReflectionProperty($this->modelClass, $this->foreignField); |
64 | 64 | $this->propertyReflection->setAccessible(true); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | { |
74 | 74 | $this->propertyReflection->setValue($model, $this->foreignId); |
75 | 75 | |
76 | - $this->models[$model->getId()] = $model; |
|
76 | + $this->models[ $model->getId() ] = $model; |
|
77 | 77 | |
78 | 78 | return $this; |
79 | 79 | } |
@@ -85,10 +85,10 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function removeModel(ModelInterface $model): ModelCollectionInterface |
87 | 87 | { |
88 | - if (isset($this->models[$model->getId()])) { |
|
88 | + if (isset($this->models[ $model->getId() ])) { |
|
89 | 89 | $this->propertyReflection->setValue($model, null); |
90 | 90 | |
91 | - unset($this->models[$model->getId()]); |
|
91 | + unset($this->models[ $model->getId() ]); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | return $this; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function setModels(array $models): ModelCollectionInterface |
103 | 103 | { |
104 | - $this->models = []; |
|
104 | + $this->models = [ ]; |
|
105 | 105 | foreach ($models as $model) { |
106 | 106 | $this->addModel($model); |
107 | 107 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function getInitialModels(): array |
124 | 124 | { |
125 | - return []; |
|
125 | + return [ ]; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function jsonSerialize(): array |
140 | 140 | { |
141 | - $serializedModels = []; |
|
141 | + $serializedModels = [ ]; |
|
142 | 142 | foreach ($this->getModels() as $model) { |
143 | - $serializedModels[] = $model->jsonSerialize(); |
|
143 | + $serializedModels[ ] = $model->jsonSerialize(); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | return $serializedModels; |