@@ -2,17 +2,17 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace SimpleMapper; |
| 4 | 4 | |
| 5 | +use Exception; |
|
| 5 | 6 | use Nette\Database\Context; |
| 6 | 7 | use Nette\Database\DriverException; |
| 7 | 8 | use Nette\Database\Table\ActiveRow as NetteDatabaseActiveRow; |
| 8 | 9 | use Nette\Database\Table\Selection as NetteDatabaseSelection; |
| 10 | +use PDOException; |
|
| 9 | 11 | use SimpleMapper\Behaviour\Behaviour; |
| 10 | 12 | use SimpleMapper\Exception\RepositoryException; |
| 11 | 13 | use SimpleMapper\Structure\EmptyStructure; |
| 12 | 14 | use SimpleMapper\Structure\Structure; |
| 13 | 15 | use Traversable; |
| 14 | -use Exception; |
|
| 15 | -use PDOException; |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * Base repository class |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace SimpleMapper; |
| 5 | 5 | |
@@ -88,14 +88,14 @@ discard block |
||
| 88 | 88 | $scopeName = lcfirst(substr($name, 5)); |
| 89 | 89 | $scope = $this->structure->getScope(static::$tableName, $scopeName); |
| 90 | 90 | if (!$scope) { |
| 91 | - throw new RepositoryException('Scope ' . $scopeName . ' is not defined for table ' . static::$tableName); |
|
| 91 | + throw new RepositoryException('Scope '.$scopeName.' is not defined for table '.static::$tableName); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - $scopeNameToCall = 'scope' . ucfirst($scope->getName()); |
|
| 94 | + $scopeNameToCall = 'scope'.ucfirst($scope->getName()); |
|
| 95 | 95 | return call_user_func_array([$this->findAll(), $scopeNameToCall], $arguments); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - throw new RepositoryException('Call to undefined method ' . get_class($this) . '::' . $name . '()'); |
|
| 98 | + throw new RepositoryException('Call to undefined method '.get_class($this).'::'.$name.'()'); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /********************************************************************\ |
@@ -149,9 +149,9 @@ discard block |
||
| 149 | 149 | * @return ActiveRow|null |
| 150 | 150 | * @throws Exception |
| 151 | 151 | */ |
| 152 | - public function insert(array $data): ?ActiveRow |
|
| 152 | + public function insert(array $data): ? ActiveRow |
|
| 153 | 153 | { |
| 154 | - $result = $this->transaction(function () use ($data) { |
|
| 154 | + $result = $this->transaction(function() use ($data) { |
|
| 155 | 155 | foreach ($this->behaviours as $behaviour) { |
| 156 | 156 | $data = $behaviour->beforeInsert($data); |
| 157 | 157 | } |
@@ -179,9 +179,9 @@ discard block |
||
| 179 | 179 | * @param array $data |
| 180 | 180 | * @return ActiveRow|null |
| 181 | 181 | */ |
| 182 | - public function update(ActiveRow $record, array $data): ?ActiveRow |
|
| 182 | + public function update(ActiveRow $record, array $data): ? ActiveRow |
|
| 183 | 183 | { |
| 184 | - $result = $this->transaction(function () use ($record, $data) { |
|
| 184 | + $result = $this->transaction(function() use ($record, $data) { |
|
| 185 | 185 | $oldRecord = clone $record; |
| 186 | 186 | |
| 187 | 187 | foreach ($this->behaviours as $behaviour) { |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | */ |
| 208 | 208 | public function delete(ActiveRow $record): bool |
| 209 | 209 | { |
| 210 | - $result = $this->transaction(function () use ($record): bool { |
|
| 210 | + $result = $this->transaction(function() use ($record): bool { |
|
| 211 | 211 | $oldRecord = clone $record; |
| 212 | 212 | |
| 213 | 213 | foreach ($this->behaviours as $behaviour) { |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | * @param string $class |
| 260 | 260 | * @return Behaviour|null |
| 261 | 261 | */ |
| 262 | - protected function getBehaviour($class): ?Behaviour |
|
| 262 | + protected function getBehaviour($class): ? Behaviour |
|
| 263 | 263 | { |
| 264 | 264 | return $this->behaviours[$class] ?? null; |
| 265 | 265 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace SimpleMapper; |
| 5 | 5 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * @param string $throughColumn |
| 127 | 127 | * @return ActiveRow|null |
| 128 | 128 | */ |
| 129 | - public function ref($key, $throughColumn = null): ?ActiveRow |
|
| 129 | + public function ref($key, $throughColumn = null): ? ActiveRow |
|
| 130 | 130 | { |
| 131 | 131 | $row = $this->record->ref($key, $throughColumn); |
| 132 | 132 | return $row instanceof IRow ? $this->prepareRecord($row) : null; |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | * @param string $throughColumn |
| 140 | 140 | * @return Selection |
| 141 | 141 | */ |
| 142 | - public function related($key, $throughColumn = null): ?Selection |
|
| 142 | + public function related($key, $throughColumn = null): ? Selection |
|
| 143 | 143 | { |
| 144 | 144 | $selection = $this->record->related($key, $throughColumn); |
| 145 | 145 | return $selection instanceof NetteDatabaseSelection ? $this->prepareSelection($selection) : null; |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace SimpleMapper\Scope; |
| 5 | 5 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace SimpleMapper; |
| 5 | 5 | |
@@ -62,12 +62,12 @@ discard block |
||
| 62 | 62 | $scopeName = lcfirst(substr($name, 5)); |
| 63 | 63 | $scope = $this->structure->getScope($this->selection->getName(), $scopeName); |
| 64 | 64 | if (!$scope) { |
| 65 | - trigger_error('Scope ' . $scopeName . ' is not defined for table ' . $this->selection->getName(), E_USER_ERROR); |
|
| 65 | + trigger_error('Scope '.$scopeName.' is not defined for table '.$this->selection->getName(), E_USER_ERROR); |
|
| 66 | 66 | } |
| 67 | 67 | return $this->where(call_user_func_array($scope->getCallback(), $arguments)); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - trigger_error('Call to undefined method ' . get_class($this) . '::' . $name . '()', E_USER_ERROR); |
|
| 70 | + trigger_error('Call to undefined method '.get_class($this).'::'.$name.'()', E_USER_ERROR); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /**********************************************************************\ |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | * @param mixed $key Primary key |
| 80 | 80 | * @return ActiveRow|null |
| 81 | 81 | */ |
| 82 | - public function get($key): ?ActiveRow |
|
| 82 | + public function get($key): ? ActiveRow |
|
| 83 | 83 | { |
| 84 | 84 | $row = $this->selection->get($key); |
| 85 | 85 | return $row instanceof NetteDatabaseActiveRow ? $this->prepareRecord($row) : null; |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * Returns one record |
| 90 | 90 | * @return ActiveRow|null |
| 91 | 91 | */ |
| 92 | - public function fetch(): ?ActiveRow |
|
| 92 | + public function fetch(): ? ActiveRow |
|
| 93 | 93 | { |
| 94 | 94 | $row = $this->selection->fetch(); |
| 95 | 95 | return $row ? $this->prepareRecord($row) : null; |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | * Returns current selection data record |
| 385 | 385 | * @return ActiveRow|null |
| 386 | 386 | */ |
| 387 | - public function current(): ?ActiveRow |
|
| 387 | + public function current(): ? ActiveRow |
|
| 388 | 388 | { |
| 389 | 389 | $row = $this->selection->current(); |
| 390 | 390 | return $row instanceof IRow ? $this->prepareRecord($row) : null; |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | * @param string $key Row ID |
| 435 | 435 | * @return ActiveRow|null |
| 436 | 436 | */ |
| 437 | - public function offsetGet($key): ?ActiveRow |
|
| 437 | + public function offsetGet($key): ? ActiveRow |
|
| 438 | 438 | { |
| 439 | 439 | $row = $this->selection->offsetGet($key); |
| 440 | 440 | return $row instanceof IRow ? $this->prepareRecord($row) : null; |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace SimpleMapper\Behaviour; |
| 5 | 5 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace SimpleMapper\Structure; |
| 5 | 5 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | { |
| 49 | 49 | foreach ($scopes as $scope) { |
| 50 | 50 | if (!($scope instanceof Scope)) { |
| 51 | - throw new SimpleMapperException('Scopes can be only of class ' . Scope::class); |
|
| 51 | + throw new SimpleMapperException('Scopes can be only of class '.Scope::class); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | $this->data[$tableName]['scopes'][$scope->getName()] = $scope; |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * @param string $scope |
| 93 | 93 | * @return Scope|null |
| 94 | 94 | */ |
| 95 | - public function getScope(string $tableName, string $scope): ?Scope |
|
| 95 | + public function getScope(string $tableName, string $scope): ? Scope |
|
| 96 | 96 | { |
| 97 | 97 | return $this->data[$tableName]['scopes'][$scope] ?? null; |
| 98 | 98 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace SimpleMapper\Structure; |
| 5 | 5 | |
@@ -58,5 +58,5 @@ discard block |
||
| 58 | 58 | * @param string $scope |
| 59 | 59 | * @return Scope|null |
| 60 | 60 | */ |
| 61 | - public function getScope(string $tableName, string $scope): ?Scope; |
|
| 61 | + public function getScope(string $tableName, string $scope): ? Scope; |
|
| 62 | 62 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace SimpleMapper\Structure; |
| 5 | 5 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @param string $scope |
| 79 | 79 | * @return Scope|null |
| 80 | 80 | */ |
| 81 | - public function getScope(string $table, string $scope): ?Scope |
|
| 81 | + public function getScope(string $table, string $scope): ? Scope |
|
| 82 | 82 | { |
| 83 | 83 | return null; |
| 84 | 84 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace SimpleMapper; |
| 5 | 5 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @param string $class |
| 69 | 69 | * @return null|Repository |
| 70 | 70 | */ |
| 71 | - public function getRepository(string $class): ?Repository |
|
| 71 | + public function getRepository(string $class): ? Repository |
|
| 72 | 72 | { |
| 73 | 73 | return $this->repositories[$class] ?? null; |
| 74 | 74 | } |