@@ -49,9 +49,9 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | public function __toString() |
| 51 | 51 | { |
| 52 | - return PHP_EOL . 'load: ' |
|
| 52 | + return PHP_EOL.'load: ' |
|
| 53 | 53 | . json_encode($this->load) |
| 54 | - . PHP_EOL . 'alterations: ' |
|
| 54 | + . PHP_EOL.'alterations: ' |
|
| 55 | 55 | . json_encode(array_keys($this->alterations)); |
| 56 | 56 | } |
| 57 | 57 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | // replaces empty strings with null or default value |
| 165 | - if (trim('' . $datass[$field_name]) === '' && $attributes->nullable()) { |
|
| 165 | + if (trim(''.$datass[$field_name]) === '' && $attributes->nullable()) { |
|
| 166 | 166 | $datass[$field_name] = $attributes->nullable() ? null : $attributes->default(); |
| 167 | 167 | } |
| 168 | 168 | |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | $unique_match = $this->connection->schema()->matchUniqueness($this->table, $this->load); |
| 222 | 222 | |
| 223 | - if(empty($unique_match)){ |
|
| 223 | + if (empty($unique_match)) { |
|
| 224 | 224 | throw new CruditesException('UNIQUE_MATCH_NOT_FOUND'); |
| 225 | 225 | } |
| 226 | 226 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | $pdo_statement = $this->executed ?? $this->prepared; |
| 62 | 62 | |
| 63 | 63 | if ($pdo_statement === null) |
| 64 | - throw new CruditesException('both executed and prepared instances are null, cannot call PDOStatement method ' . $method); |
|
| 64 | + throw new CruditesException('both executed and prepared instances are null, cannot call PDOStatement method '.$method); |
|
| 65 | 65 | |
| 66 | 66 | if (!method_exists($pdo_statement, $method)) |
| 67 | 67 | throw new \BadMethodCallException("method $method not found in PDOStatement instance"); |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | throw new CruditesException('PDO_PREPARE_STRING'); |
| 117 | 117 | } catch (\PDOException $e) { |
| 118 | - throw new CruditesException('PDO_EXCEPTION: ' . $e->getMessage(), $e->getCode(), $e); |
|
| 118 | + throw new CruditesException('PDO_EXCEPTION: '.$e->getMessage(), $e->getCode(), $e); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | return $this; |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | public function ret($mode = \PDO::FETCH_ASSOC, $fetch_argument = null, $ctor_args = null) |
| 139 | 139 | { |
| 140 | - if($mode === \PDO::FETCH_CLASS) |
|
| 140 | + if ($mode === \PDO::FETCH_CLASS) |
|
| 141 | 141 | return $this->executed->fetchAll($mode, $fetch_argument, $ctor_args); |
| 142 | 142 | |
| 143 | 143 | return $this->executed->fetchAll($mode); |
@@ -43,8 +43,9 @@ discard block |
||
| 43 | 43 | $this->statement = $statement; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - if ($this->statement instanceof \PDOStatement) |
|
| 47 | - $this->prepared = $this->statement; |
|
| 46 | + if ($this->statement instanceof \PDOStatement) { |
|
| 47 | + $this->prepared = $this->statement; |
|
| 48 | + } |
|
| 48 | 49 | |
| 49 | 50 | $this->run($bindings); |
| 50 | 51 | } |
@@ -60,11 +61,13 @@ discard block |
||
| 60 | 61 | // make senses for chronology and error handling |
| 61 | 62 | $pdo_statement = $this->executed ?? $this->prepared; |
| 62 | 63 | |
| 63 | - if ($pdo_statement === null) |
|
| 64 | - throw new CruditesException('both executed and prepared instances are null, cannot call PDOStatement method ' . $method); |
|
| 64 | + if ($pdo_statement === null) { |
|
| 65 | + throw new CruditesException('both executed and prepared instances are null, cannot call PDOStatement method ' . $method); |
|
| 66 | + } |
|
| 65 | 67 | |
| 66 | - if (!method_exists($pdo_statement, $method)) |
|
| 67 | - throw new \BadMethodCallException("method $method not found in PDOStatement instance"); |
|
| 68 | + if (!method_exists($pdo_statement, $method)) { |
|
| 69 | + throw new \BadMethodCallException("method $method not found in PDOStatement instance"); |
|
| 70 | + } |
|
| 68 | 71 | |
| 69 | 72 | return call_user_func_array([$pdo_statement, $method], $args); |
| 70 | 73 | } |
@@ -137,8 +140,9 @@ discard block |
||
| 137 | 140 | */ |
| 138 | 141 | public function ret($mode = \PDO::FETCH_ASSOC, $fetch_argument = null, $ctor_args = null) |
| 139 | 142 | { |
| 140 | - if($mode === \PDO::FETCH_CLASS) |
|
| 141 | - return $this->executed->fetchAll($mode, $fetch_argument, $ctor_args); |
|
| 143 | + if($mode === \PDO::FETCH_CLASS) { |
|
| 144 | + return $this->executed->fetchAll($mode, $fetch_argument, $ctor_args); |
|
| 145 | + } |
|
| 142 | 146 | |
| 143 | 147 | return $this->executed->fetchAll($mode); |
| 144 | 148 | } |
@@ -189,11 +193,13 @@ discard block |
||
| 189 | 193 | */ |
| 190 | 194 | public function errorInfo(): array |
| 191 | 195 | { |
| 192 | - if ($this->executed !== null) |
|
| 193 | - return $this->executed->errorInfo(); |
|
| 196 | + if ($this->executed !== null) { |
|
| 197 | + return $this->executed->errorInfo(); |
|
| 198 | + } |
|
| 194 | 199 | |
| 195 | - if ($this->prepared !== null) |
|
| 196 | - return $this->prepared->errorInfo(); |
|
| 200 | + if ($this->prepared !== null) { |
|
| 201 | + return $this->prepared->errorInfo(); |
|
| 202 | + } |
|
| 197 | 203 | |
| 198 | 204 | return $this->pdo->errorInfo(); |
| 199 | 205 | } |