@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | public function getTableName() |
82 | 82 | { |
83 | 83 | $className = explode('\\', get_called_class()); |
84 | - $table = strtolower(end($className).'s'); |
|
84 | + $table = strtolower(end($className) . 's'); |
|
85 | 85 | |
86 | 86 | return $table; |
87 | 87 | } |
@@ -154,17 +154,17 @@ discard block |
||
154 | 154 | public function update() |
155 | 155 | { |
156 | 156 | $bindNameParameters = []; |
157 | - $sqlUpdate = 'UPDATE '.$this->getTableName().' SET '; |
|
157 | + $sqlUpdate = 'UPDATE ' . $this->getTableName() . ' SET '; |
|
158 | 158 | foreach ($this->properties as $columnName => $columnValue) { |
159 | 159 | if ($columnName == 'id') { |
160 | 160 | continue; |
161 | 161 | } |
162 | - $bindColumnName = ':'.$columnName; |
|
162 | + $bindColumnName = ':' . $columnName; |
|
163 | 163 | $sqlUpdate .= "$columnName = $bindColumnName,"; |
164 | 164 | $bindNameParameters[$bindColumnName] = $columnValue; |
165 | 165 | } |
166 | 166 | //Remove the last comma in sql command then join it to the other query part. |
167 | - $sqlUpdate = substr($sqlUpdate, 0, -1).' WHERE id = :id'; |
|
167 | + $sqlUpdate = substr($sqlUpdate, 0, -1) . ' WHERE id = :id'; |
|
168 | 168 | $sqlStatement = $this->databaseConnection->prepare($sqlUpdate); |
169 | 169 | $bindNameParameters[':id'] = $this->properties['id']; |
170 | 170 | $sqlStatement->execute($bindNameParameters); |
@@ -182,18 +182,18 @@ discard block |
||
182 | 182 | $columnNames = ''; |
183 | 183 | $columnValues = ''; |
184 | 184 | $bindNameParameters = []; |
185 | - $sqlCreate = 'INSERT'.' INTO '.$this->getTableName().' ('; |
|
185 | + $sqlCreate = 'INSERT' . ' INTO ' . $this->getTableName() . ' ('; |
|
186 | 186 | foreach ($this->properties as $columnName => $columnValue) { |
187 | - $bindColumnName = ':'.$columnName; |
|
188 | - $columnNames .= $columnName.','; |
|
189 | - $columnValues .= $bindColumnName.','; |
|
187 | + $bindColumnName = ':' . $columnName; |
|
188 | + $columnNames .= $columnName . ','; |
|
189 | + $columnValues .= $bindColumnName . ','; |
|
190 | 190 | $bindNameParameters[$bindColumnName] = $columnValue; |
191 | 191 | } |
192 | 192 | // Remove ending comma and whitespace. |
193 | 193 | $columnNames = substr($columnNames, 0, -1); |
194 | 194 | $columnValues = substr($columnValues, 0, -1); |
195 | 195 | |
196 | - $sqlCreate .= $columnNames.') VALUES ('.$columnValues.')'; |
|
196 | + $sqlCreate .= $columnNames . ') VALUES (' . $columnValues . ')'; |
|
197 | 197 | $sqlStatement = $this->databaseConnection->prepare($sqlCreate); |
198 | 198 | $sqlStatement->execute($bindNameParameters); |
199 | 199 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | */ |
234 | 234 | public function delete($id) |
235 | 235 | { |
236 | - $sql = 'DELETE'.' FROM '.self::getTableName().' WHERE id = '.$id; |
|
236 | + $sql = 'DELETE' . ' FROM ' . self::getTableName() . ' WHERE id = ' . $id; |
|
237 | 237 | $sqlStatment = $this->databaseConnection->prepare($sql); |
238 | 238 | $sqlStatment->execute(); |
239 | 239 |
@@ -22,16 +22,16 @@ |
||
22 | 22 | |
23 | 23 | switch ($driver) { |
24 | 24 | case 'sqlite': |
25 | - $dsn = $driver.'::memory:'; |
|
25 | + $dsn = $driver . '::memory:'; |
|
26 | 26 | break; |
27 | 27 | case 'mysql': |
28 | 28 | case 'postgres': |
29 | 29 | if (strcasecmp($driver, 'postgres') == 0) { |
30 | 30 | $driver = 'pgsql'; |
31 | 31 | } |
32 | - $dsn = $driver.':host='.$config['HOSTNAME'].';dbname='.$config['DBNAME']; |
|
32 | + $dsn = $driver . ':host=' . $config['HOSTNAME'] . ';dbname=' . $config['DBNAME']; |
|
33 | 33 | if (isset($config['PORT'])) { |
34 | - $dsn .= ';port='.$config['PORT']; |
|
34 | + $dsn .= ';port=' . $config['PORT']; |
|
35 | 35 | } |
36 | 36 | break; |
37 | 37 | default: |
@@ -7,6 +7,6 @@ |
||
7 | 7 | { |
8 | 8 | public function __construct($id) |
9 | 9 | { |
10 | - parent::__construct('The requested Model with '.$id.' does not exist'); |
|
10 | + parent::__construct('The requested Model with ' . $id . ' does not exist'); |
|
11 | 11 | } |
12 | 12 | } |
@@ -37,9 +37,9 @@ |
||
37 | 37 | $this->databaseConnection->shouldReceive('createConnection')->with('sqlite::memory:')->once()->andReturn(''); |
38 | 38 | $this->model->expects($this->any()) |
39 | 39 | ->method('getTableName') |
40 | - ->will($this->returnValue(strtolower(get_class($this->model).'s'))); |
|
40 | + ->will($this->returnValue(strtolower(get_class($this->model) . 's'))); |
|
41 | 41 | |
42 | - $this->assertEquals($this->model->getTableName(), strtolower(get_class($this->model).'s')); |
|
42 | + $this->assertEquals($this->model->getTableName(), strtolower(get_class($this->model) . 's')); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | public function testGetReturnsAnObjectWhenIdIsFoundInDatabase() |