@@ -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 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | { |
| 53 | 53 | $modelClass = $this->getModelClass(); |
| 54 | 54 | |
| 55 | - $this->logger->info('model: find model {model} with id {id}', ['model' => $modelClass, 'id' => $id]); |
|
| 55 | + $this->logger->info('model: find model {model} with id {id}', [ 'model' => $modelClass, 'id' => $id ]); |
|
| 56 | 56 | |
| 57 | 57 | if ($this->cache->has($id)) { |
| 58 | 58 | return $this->cache->get($id); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | if (false === $row) { |
| 66 | 66 | $this->logger->warning( |
| 67 | 67 | 'model: model {model} with id {id} not found', |
| 68 | - ['model' => $modelClass, 'id' => $id] |
|
| 68 | + [ 'model' => $modelClass, 'id' => $id ] |
|
| 69 | 69 | ); |
| 70 | 70 | |
| 71 | 71 | return null; |
@@ -83,13 +83,13 @@ discard block |
||
| 83 | 83 | * |
| 84 | 84 | * @return null|ModelInterface |
| 85 | 85 | */ |
| 86 | - public function findOneBy(array $criteria = []) |
|
| 86 | + public function findOneBy(array $criteria = [ ]) |
|
| 87 | 87 | { |
| 88 | 88 | $modelClass = $this->getModelClass(); |
| 89 | 89 | |
| 90 | 90 | $this->logger->info( |
| 91 | 91 | 'model: find model {model} with criteria {criteria}', |
| 92 | - ['model' => $modelClass, 'criteria' => $criteria] |
|
| 92 | + [ 'model' => $modelClass, 'criteria' => $criteria ] |
|
| 93 | 93 | ); |
| 94 | 94 | |
| 95 | 95 | $qb = $this->getFindByQueryBuilder($criteria)->setMaxResults(1); |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | if (false === $row) { |
| 99 | 99 | $this->logger->warning( |
| 100 | 100 | 'model: model {model} with criteria {criteria} not found', |
| 101 | - ['model' => $modelClass, 'criteria' => $criteria] |
|
| 101 | + [ 'model' => $modelClass, 'criteria' => $criteria ] |
|
| 102 | 102 | ); |
| 103 | 103 | |
| 104 | 104 | return null; |
@@ -112,24 +112,24 @@ discard block |
||
| 112 | 112 | * |
| 113 | 113 | * @return ModelInterface[]|array |
| 114 | 114 | */ |
| 115 | - public function findBy(array $criteria = []): array |
|
| 115 | + public function findBy(array $criteria = [ ]): array |
|
| 116 | 116 | { |
| 117 | 117 | $modelClass = $this->getModelClass(); |
| 118 | 118 | |
| 119 | 119 | $this->logger->info( |
| 120 | 120 | 'model: find model {model} with criteria {criteria}', |
| 121 | - ['model' => $modelClass, 'criteria' => $criteria] |
|
| 121 | + [ 'model' => $modelClass, 'criteria' => $criteria ] |
|
| 122 | 122 | ); |
| 123 | 123 | |
| 124 | 124 | $rows = $this->getFindByQueryBuilder($criteria)->execute()->fetchAll(\PDO::FETCH_ASSOC); |
| 125 | 125 | |
| 126 | - if ([] === $rows) { |
|
| 127 | - return []; |
|
| 126 | + if ([ ] === $rows) { |
|
| 127 | + return [ ]; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - $models = []; |
|
| 130 | + $models = [ ]; |
|
| 131 | 131 | foreach ($rows as $row) { |
| 132 | - $models[] = $this->fromRow($row); |
|
| 132 | + $models[ ] = $this->fromRow($row); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | return $models; |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | * |
| 141 | 141 | * @return QueryBuilder |
| 142 | 142 | */ |
| 143 | - private function getFindByQueryBuilder(array $criteria = []): QueryBuilder |
|
| 143 | + private function getFindByQueryBuilder(array $criteria = [ ]): QueryBuilder |
|
| 144 | 144 | { |
| 145 | 145 | $qb = $this->connection->createQueryBuilder(); |
| 146 | 146 | $qb->select('*')->from($this->getTable()); |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | { |
| 161 | 161 | $this->logger->info( |
| 162 | 162 | 'model: insert model {model} with id {id}', |
| 163 | - ['model' => get_class($model), 'id' => $model->getId()] |
|
| 163 | + [ 'model' => get_class($model), 'id' => $model->getId() ] |
|
| 164 | 164 | ); |
| 165 | 165 | |
| 166 | 166 | $this->connection->insert($this->getTable(), $model->toRow()); |
@@ -175,10 +175,10 @@ discard block |
||
| 175 | 175 | { |
| 176 | 176 | $this->logger->info( |
| 177 | 177 | 'model: update model {model} with id {id}', |
| 178 | - ['model' => get_class($model), 'id' => $model->getId()] |
|
| 178 | + [ 'model' => get_class($model), 'id' => $model->getId() ] |
|
| 179 | 179 | ); |
| 180 | 180 | |
| 181 | - $this->connection->update($this->getTable(), $model->toRow(), ['id' => $model->getId()]); |
|
| 181 | + $this->connection->update($this->getTable(), $model->toRow(), [ 'id' => $model->getId() ]); |
|
| 182 | 182 | |
| 183 | 183 | $this->cache->set($model); |
| 184 | 184 | } |
@@ -190,10 +190,10 @@ discard block |
||
| 190 | 190 | { |
| 191 | 191 | $this->logger->info( |
| 192 | 192 | 'model: delete model {model} with id {id}', |
| 193 | - ['model' => get_class($model), 'id' => $model->getId()] |
|
| 193 | + [ 'model' => get_class($model), 'id' => $model->getId() ] |
|
| 194 | 194 | ); |
| 195 | 195 | |
| 196 | - $this->connection->delete($this->getTable(), ['id' => $model->getId()]); |
|
| 196 | + $this->connection->delete($this->getTable(), [ 'id' => $model->getId() ]); |
|
| 197 | 197 | |
| 198 | 198 | $this->cache->remove($model->getId()); |
| 199 | 199 | } |