@@ -61,12 +61,12 @@ |
||
61 | 61 | $scopeName = lcfirst(substr($name, 5)); |
62 | 62 | $scope = $this->structure->getScope($this->selection->getName(), $scopeName); |
63 | 63 | if (!$scope) { |
64 | - trigger_error('Scope ' . $scopeName . ' is not defined for table ' . $this->selection->getName(), E_USER_ERROR); |
|
64 | + trigger_error('Scope '.$scopeName.' is not defined for table '.$this->selection->getName(), E_USER_ERROR); |
|
65 | 65 | } |
66 | 66 | return $this->where(call_user_func_array($scope->getCallback(), $arguments)); |
67 | 67 | } |
68 | 68 | |
69 | - trigger_error('Call to undefined method ' . get_class($this) . '::' . $name . '()', E_USER_ERROR); |
|
69 | + trigger_error('Call to undefined method '.get_class($this).'::'.$name.'()', E_USER_ERROR); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /**********************************************************************\ |
@@ -44,7 +44,7 @@ |
||
44 | 44 | * @param string $scope |
45 | 45 | * @return Scope|null |
46 | 46 | */ |
47 | - public function getScope(string $table, string $scope): ?Scope |
|
47 | + public function getScope(string $table, string $scope): ? Scope |
|
48 | 48 | { |
49 | 49 | return null; |
50 | 50 | } |
@@ -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 |
@@ -87,14 +87,14 @@ discard block |
||
87 | 87 | $scopeName = lcfirst(substr($name, 5)); |
88 | 88 | $scope = $this->structure->getScope(static::$tableName, $scopeName); |
89 | 89 | if (!$scope) { |
90 | - throw new RepositoryException('Scope ' . $scopeName . ' is not defined for table ' . static::$tableName); |
|
90 | + throw new RepositoryException('Scope '.$scopeName.' is not defined for table '.static::$tableName); |
|
91 | 91 | } |
92 | 92 | |
93 | - $scopeNameToCall = 'scope' . ucfirst($scope->getName()); |
|
93 | + $scopeNameToCall = 'scope'.ucfirst($scope->getName()); |
|
94 | 94 | return call_user_func_array([$this->findAll(), $scopeNameToCall], $arguments); |
95 | 95 | } |
96 | 96 | |
97 | - throw new RepositoryException('Call to undefined method ' . get_class($this) . '::' . $name . '()'); |
|
97 | + throw new RepositoryException('Call to undefined method '.get_class($this).'::'.$name.'()'); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /********************************************************************\ |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | * @return ActiveRow|null |
149 | 149 | * @throws Exception |
150 | 150 | */ |
151 | - public function insert(array $data): ?ActiveRow |
|
151 | + public function insert(array $data): ? ActiveRow |
|
152 | 152 | { |
153 | - $result = $this->transaction(function () use ($data) { |
|
153 | + $result = $this->transaction(function() use ($data) { |
|
154 | 154 | foreach ($this->behaviours as $behaviour) { |
155 | 155 | $data = $behaviour->beforeInsert($data); |
156 | 156 | } |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | * @param array $data |
179 | 179 | * @return ActiveRow|null |
180 | 180 | */ |
181 | - public function update(ActiveRow $record, array $data): ?ActiveRow |
|
181 | + public function update(ActiveRow $record, array $data): ? ActiveRow |
|
182 | 182 | { |
183 | - $result = $this->transaction(function () use ($record, $data) { |
|
183 | + $result = $this->transaction(function() use ($record, $data) { |
|
184 | 184 | $oldRecord = clone $record; |
185 | 185 | |
186 | 186 | foreach ($this->behaviours as $behaviour) { |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | public function delete(ActiveRow $record): bool |
208 | 208 | { |
209 | - $result = $this->transaction(function () use ($record): bool { |
|
209 | + $result = $this->transaction(function() use ($record): bool { |
|
210 | 210 | $oldRecord = clone $record; |
211 | 211 | |
212 | 212 | foreach ($this->behaviours as $behaviour) { |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @param string $class |
259 | 259 | * @return Behaviour|null |
260 | 260 | */ |
261 | - protected function getBehaviour($class): ?Behaviour |
|
261 | + protected function getBehaviour($class): ? Behaviour |
|
262 | 262 | { |
263 | 263 | return $this->behaviours[$class] ?? null; |
264 | 264 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | { |
48 | 48 | foreach ($scopes as $scope) { |
49 | 49 | if (!($scope instanceof Scope)) { |
50 | - throw new SimpleMapperException('Scopes can be only of class ' . Scope::class); |
|
50 | + throw new SimpleMapperException('Scopes can be only of class '.Scope::class); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | $this->data[$tableName]['scopes'][$scope->getName()] = $scope; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @param string $scope |
92 | 92 | * @return Scope|null |
93 | 93 | */ |
94 | - public function getScope(string $tableName, string $scope): ?Scope |
|
94 | + public function getScope(string $tableName, string $scope): ? Scope |
|
95 | 95 | { |
96 | 96 | return $this->data[$tableName]['scopes'][$scope] ?? null; |
97 | 97 | } |
@@ -57,5 +57,5 @@ |
||
57 | 57 | * @param string $scope |
58 | 58 | * @return Scope|null |
59 | 59 | */ |
60 | - public function getScope(string $tableName, string $scope): ?Scope; |
|
60 | + public function getScope(string $tableName, string $scope): ? Scope; |
|
61 | 61 | } |
@@ -67,7 +67,7 @@ |
||
67 | 67 | * @param string $class |
68 | 68 | * @return null|Repository |
69 | 69 | */ |
70 | - public function getRepository(string $class): ?Repository |
|
70 | + public function getRepository(string $class): ? Repository |
|
71 | 71 | { |
72 | 72 | return $this->repositories[$class] ?? null; |
73 | 73 | } |