@@ -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 | |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | /** @var ModelInterface $modelClass */ |
41 | 41 | $modelClass = $this->getModelClass(); |
42 | 42 | |
43 | - $this->logger->info('Find model {model} with id {id}', ['model' => $modelClass, 'id' => $id]); |
|
43 | + $this->logger->info('Find model {model} with id {id}', [ 'model' => $modelClass, 'id' => $id ]); |
|
44 | 44 | |
45 | 45 | $qb = $this->connection->createQueryBuilder(); |
46 | 46 | $qb->select('*')->from($this->getTable())->where($qb->expr()->eq('id', ':id'))->setParameter('id', $id); |
47 | 47 | |
48 | 48 | $row = $qb->execute()->fetch(\PDO::FETCH_ASSOC); |
49 | 49 | if (false === $row) { |
50 | - $this->logger->warning('Model {model} with id {id} not found', ['model' => $modelClass, 'id' => $id]); |
|
50 | + $this->logger->warning('Model {model} with id {id} not found', [ 'model' => $modelClass, 'id' => $id ]); |
|
51 | 51 | |
52 | 52 | return null; |
53 | 53 | } |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @return null|ModelInterface |
62 | 62 | */ |
63 | - public function findOneBy(array $criteria = []) |
|
63 | + public function findOneBy(array $criteria = [ ]) |
|
64 | 64 | { |
65 | 65 | /** @var ModelInterface $modelClass */ |
66 | 66 | $modelClass = $this->getModelClass(); |
67 | 67 | |
68 | 68 | $this->logger->info( |
69 | 69 | 'Find model {model} by criteria {criteria}', |
70 | - ['model' => $modelClass, 'criteria' => $criteria] |
|
70 | + [ 'model' => $modelClass, 'criteria' => $criteria ] |
|
71 | 71 | ); |
72 | 72 | |
73 | 73 | $qb = $this->getFindByQueryBuilder($criteria)->setMaxResults(1); |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | if (false === $row) { |
77 | 77 | $this->logger->warning( |
78 | 78 | 'Model {model} by criteria {criteria} not found', |
79 | - ['model' => $modelClass, 'criteria' => $criteria] |
|
79 | + [ 'model' => $modelClass, 'criteria' => $criteria ] |
|
80 | 80 | ); |
81 | 81 | |
82 | 82 | return null; |
@@ -90,25 +90,25 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return ModelInterface[]|array |
92 | 92 | */ |
93 | - public function findBy(array $criteria = []): array |
|
93 | + public function findBy(array $criteria = [ ]): array |
|
94 | 94 | { |
95 | 95 | /** @var ModelInterface $modelClass */ |
96 | 96 | $modelClass = $this->getModelClass(); |
97 | 97 | |
98 | 98 | $this->logger->info( |
99 | 99 | 'Find model {model} by criteria {criteria}', |
100 | - ['model' => $modelClass, 'criteria' => $criteria] |
|
100 | + [ 'model' => $modelClass, 'criteria' => $criteria ] |
|
101 | 101 | ); |
102 | 102 | |
103 | 103 | $rows = $this->getFindByQueryBuilder($criteria)->execute()->fetchAll(\PDO::FETCH_ASSOC); |
104 | 104 | |
105 | - if ([] === $rows) { |
|
106 | - return []; |
|
105 | + if ([ ] === $rows) { |
|
106 | + return [ ]; |
|
107 | 107 | } |
108 | 108 | |
109 | - $models = []; |
|
109 | + $models = [ ]; |
|
110 | 110 | foreach ($rows as $row) { |
111 | - $models[] = $modelClass::fromRow($row); |
|
111 | + $models[ ] = $modelClass::fromRow($row); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | return $models; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @return QueryBuilder |
121 | 121 | */ |
122 | - private function getFindByQueryBuilder(array $criteria = []): QueryBuilder |
|
122 | + private function getFindByQueryBuilder(array $criteria = [ ]): QueryBuilder |
|
123 | 123 | { |
124 | 124 | $qb = $this->connection->createQueryBuilder(); |
125 | 125 | $qb->select('*')->from($this->getTable()); |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | { |
140 | 140 | $this->logger->info( |
141 | 141 | 'Insert model {model} with id {id}', |
142 | - ['model' => get_class($model), 'id' => $model->getId()] |
|
142 | + [ 'model' => get_class($model), 'id' => $model->getId() ] |
|
143 | 143 | ); |
144 | 144 | |
145 | 145 | $this->connection->insert($this->getTable(), $model->toRow()); |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | { |
153 | 153 | $this->logger->info( |
154 | 154 | 'Update model {model} with id {id}', |
155 | - ['model' => get_class($model), 'id' => $model->getId()] |
|
155 | + [ 'model' => get_class($model), 'id' => $model->getId() ] |
|
156 | 156 | ); |
157 | 157 | |
158 | - $this->connection->update($this->getTable(), $model->toRow(), ['id' => $model->getId()]); |
|
158 | + $this->connection->update($this->getTable(), $model->toRow(), [ 'id' => $model->getId() ]); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
@@ -165,10 +165,10 @@ discard block |
||
165 | 165 | { |
166 | 166 | $this->logger->info( |
167 | 167 | 'Delete model {model} with id {id}', |
168 | - ['model' => get_class($model), 'id' => $model->getId()] |
|
168 | + [ 'model' => get_class($model), 'id' => $model->getId() ] |
|
169 | 169 | ); |
170 | 170 | |
171 | - $this->connection->delete($this->getTable(), ['id' => $model->getId()]); |
|
171 | + $this->connection->delete($this->getTable(), [ 'id' => $model->getId() ]); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |