Completed
Push — develop ( d28428...d28428 )
by Simon
02:20
created
src/BaseConnection.php 5 patches
Doc Comments   +7 added lines, -1 removed lines patch added patch discarded remove patch
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 
390 390
 	/**
391 391
 	 * Bind named and positional parameters to a PDOStatement.
392
-	 * @param  PDOStatement $statement
392
+	 * @param  \PDOStatement $statement
393 393
 	 * @param  array        $params
394 394
 	 * @return void
395 395
 	 */
@@ -434,6 +434,12 @@  discard block
 block discarded – undo
434 434
 
435 435
 	}
436 436
 
437
+	/**
438
+	 * @param string $option
439
+	 * @param string $default
440
+	 *
441
+	 * @return string
442
+	 */
437 443
 	protected function getOption( $option, $default = null ) {
438 444
 		return isset($this->dsn->options[$option]) ? $this->dsn->options[$option] : $default;
439 445
 	}
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,6 @@
 block discarded – undo
15 15
 use yolk\contracts\profiler\ProfilerAwareTrait;
16 16
 use yolk\contracts\profiler\ProfilerAware;
17 17
 use yolk\contracts\support\Dumpable;
18
-
19 18
 use yolk\database\exceptions\DatabaseException;
20 19
 use yolk\database\exceptions\ConnectionException;
21 20
 use yolk\database\exceptions\NotConnectedException;
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -346,15 +346,15 @@
 block discarded – undo
346 346
 
347 347
 		$name = trim($name);
348 348
 
349
-        if( $name == '*' )
350
-            return $name;
349
+		if( $name == '*' )
350
+			return $name;
351 351
 
352 352
 		// ANSI-SQL (everything else) says to use double quotes to quote identifiers
353
-        $char = '"';
353
+		$char = '"';
354 354
 
355 355
 		// MySQL uses backticks cos it's special
356 356
 		if( $this->dsn->isMySQL() )
357
-        	$char = '`';
357
+			$char = '`';
358 358
 
359 359
 		return $char. $name. $char;
360 360
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
 
63 63
 		// check the PDO driver is available
64 64
 		elseif( !in_array($this->dsn->type, \PDO::getAvailableDrivers()) )
65
-			throw new DatabaseException("The {$this->dsn->type} PDO driver is not currently installed");
65
+			throw new DatabaseException("the {$this->dsn->type} PDO driver is not currently installed");
66 66
 
67 67
 	}
68 68
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 			);
82 82
 
83 83
 			$this->pdo->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC);
84
-			$this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);           // always use exceptions
84
+			$this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); // always use exceptions
85 85
 
86 86
 			$this->setCharacterSet(
87 87
 				$this->getOption('charset', 'UTF8'),
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 
129 129
 	public function prepare( $statement ) {
130 130
 
131
-		if( ! $statement instanceof \PDOStatement  ) {
131
+		if( !$statement instanceof \PDOStatement ) {
132 132
 
133 133
 			$this->connect();
134 134
 
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 		if( $this->dsn->isMySQL() )
357 357
         	$char = '`';
358 358
 
359
-		return $char. $name. $char;
359
+		return $char.$name.$char;
360 360
 
361 361
 	}
362 362
 
@@ -450,10 +450,10 @@  discard block
 block discarded – undo
450 450
 		if( !$charset ) 
451 451
 			throw new DatabaseException('No character set specified');
452 452
 
453
-		$sql = 'SET NAMES '. $this->pdo->quote($charset);
453
+		$sql = 'SET NAMES '.$this->pdo->quote($charset);
454 454
 
455 455
 		if( $collation )
456
-			$sql .= ' COLLATE '. $this->pdo->quote($collation);
456
+			$sql .= ' COLLATE '.$this->pdo->quote($collation);
457 457
 
458 458
 		$this->pdo->exec($sql);
459 459
 
Please login to merge, or discard this patch.
src/DSN.php 2 patches
Doc Comments   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,6 +32,9 @@  discard block
 block discarded – undo
32 32
 
33 33
 	protected $config;
34 34
 
35
+	/**
36
+	 * @param string $config
37
+	 */
35 38
 	public static function fromString( $config ) {
36 39
 
37 40
 		// parse the string into some components
@@ -85,7 +88,6 @@  discard block
 block discarded – undo
85 88
 	 * pass - user's password
86 89
 	 * db - name of the database schema to connect to
87 90
 	 * options - an array of database specific options
88
-	 * @param array $dsn
89 91
 	 */
90 92
 	public function __construct( array $config ) {
91 93
 
@@ -120,7 +122,7 @@  discard block
 block discarded – undo
120 122
 	/**
121 123
 	 * Dynamic property access.
122 124
 	 * @param  string $key
123
-	 * @return mixed
125
+	 * @return string|null
124 126
 	 */
125 127
 	public function __get( $key ) {
126 128
 		return isset($this->config[$key]) ? $this->config[$key] : null;
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
 		// no point continuing if it went wrong
41 41
 		if( !$parts || empty($parts['scheme']) )
42
-			throw new ConfigurationException('Invalid DSN string: '. $config);
42
+			throw new ConfigurationException('Invalid DSN string: '.$config);
43 43
 
44 44
 		// use a closure to save loads of duplicate logic
45 45
 		$select = function( $k, array $arr ) {
@@ -141,22 +141,22 @@  discard block
 block discarded – undo
141 141
 	 */
142 142
 	public function toString() {
143 143
 
144
-		$str = $this->config['type']. '://';
144
+		$str = $this->config['type'].'://';
145 145
 
146 146
 		if( $this->config['user'] ) {
147 147
 			$str .= $this->config['user'];
148 148
 			if( $this->config['pass'] )
149
-				$str .= ':'. $this->config['pass'];
149
+				$str .= ':'.$this->config['pass'];
150 150
 			$str .= '@';
151 151
 		}
152 152
 
153 153
 		if( $this->config['host'] ) {
154 154
 			$str .= $this->config['host'];
155 155
 			if( $this->config['port'] )
156
-				$str .= ':'. $this->config['port'];
156
+				$str .= ':'.$this->config['port'];
157 157
 		}
158 158
 
159
-		$str .= '/'. $this->config['db'];
159
+		$str .= '/'.$this->config['db'];
160 160
 
161 161
 		if( $this->config['options'] ) {
162 162
 			$str .= '?';
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 				break;
204 204
 
205 205
 			default:
206
-				throw new ConfigurationException('Invalid database type: '. $config['type']);
206
+				throw new ConfigurationException('Invalid database type: '.$config['type']);
207 207
 
208 208
 		}
209 209
 
Please login to merge, or discard this patch.
src/query/BaseQuery.php 2 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -92,6 +92,9 @@  discard block
 block discarded – undo
92 92
 		return $this;
93 93
 	}
94 94
 
95
+	/**
96
+	 * @param string $operator
97
+	 */
95 98
 	public function where( $column, $operator, $value = null ) {
96 99
 
97 100
 		// shortcut for equals
@@ -302,6 +305,11 @@  discard block
 block discarded – undo
302 305
 
303 306
 	}
304 307
 
308
+	/**
309
+	 * @param string $operator
310
+	 *
311
+	 * @return string
312
+	 */
305 313
 	protected function getParameterName( $column, $operator ) {
306 314
 
307 315
 		$suffixes = [
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 		foreach( $this->where as $i => $clause ) {
210 210
 			if( is_array($clause) )
211 211
 				$clause = implode(' ', $clause);
212
-			$sql[] = ($i ? 'AND ' : 'WHERE '). $clause;
212
+			$sql[] = ($i ? 'AND ' : 'WHERE ').$clause;
213 213
 		}
214 214
 
215 215
 		return $sql;
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 		if( $this->order ) {
224 224
 			$order = 'ORDER BY ';
225 225
 			foreach( $this->order as $column => $dir ) {
226
-				$order .= $column. ' '. $dir. ', ';
226
+				$order .= $column.' '.$dir.', ';
227 227
 			}
228 228
 			$sql[] = trim($order, ', ');
229 229
 		}
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 		if( strpos($spec, '(') !== false )
263 263
 			return $spec;
264 264
 
265
-		foreach( [' AS ', ' ', '.'] as $sep) {
265
+		foreach( [' AS ', ' ', '.'] as $sep ) {
266 266
 			if( $pos = strripos($spec, $sep) ) {
267 267
 				return
268 268
 					$this->quoteIdentifier(substr($spec, 0, $pos)).
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 			$name = substr($name, $pos + 1);
324 324
 
325 325
 		if( isset($suffixes[$operator]) )
326
-			$name .= '_'. $suffixes[$operator];
326
+			$name .= '_'.$suffixes[$operator];
327 327
 
328 328
 		return $name;
329 329
 
Please login to merge, or discard this patch.
src/adapters/MySQLConnection.php 1 patch
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@
 block discarded – undo
15 15
 use yolk\database\DSN;
16 16
 use yolk\database\exceptions\ConfigurationException;
17 17
 
18
-class MySQLConnection extends BaseConnection {
18
+class MySQLConnection extends BaseConnection {
19 19
 
20
-	public function __construct( DSN $dsn ) {
20
+	public function __construct( DSN $dsn ) {
21 21
 
22 22
 		if( !$dsn->isMySQL() )
23 23
 			throw new ConfigurationException(sprintf("\\%s expects a DSN of type '%s', '%s' given", __CLASS__, DSN::TYPE_MYSQL, $dsn->type));
Please login to merge, or discard this patch.
src/adapters/PgSQLConnection.php 1 patch
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@
 block discarded – undo
15 15
 use yolk\database\DSN;
16 16
 use yolk\database\exceptions\ConfigurationException;
17 17
 
18
-class PgSQLConnection extends BaseConnection {
18
+class PgSQLConnection extends BaseConnection {
19 19
 
20
-	public function __construct( DSN $dsn ) {
20
+	public function __construct( DSN $dsn ) {
21 21
 
22 22
 		if( !$dsn->isPgSQL() )
23 23
 			throw new ConfigurationException(sprintf("\\%s expects a DSN of type '%s', '%s' given", __CLASS__, DSN::TYPE_PGSQL, $dsn->type));
Please login to merge, or discard this patch.
src/adapters/SQLiteConnection.php 1 patch
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@
 block discarded – undo
15 15
 use yolk\database\DSN;
16 16
 use yolk\database\exceptions\ConfigurationException;
17 17
 
18
-class SQLiteConnection extends BaseConnection {
18
+class SQLiteConnection extends BaseConnection {
19 19
 
20
-	public function __construct( DSN $dsn ) {
20
+	public function __construct( DSN $dsn ) {
21 21
 
22 22
 		if( !$dsn->isSQLite() )
23 23
 			throw new ConfigurationException(sprintf("\\%s expects a DSN of type '%s', '%s' given", __CLASS__, DSN::TYPE_SQLITE, $dsn->type));
Please login to merge, or discard this patch.
src/exceptions/ConfigurationException.php 1 patch
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,9 +14,9 @@
 block discarded – undo
14 14
 /**
15 15
  * Thrown if a database configuration is invalid.
16 16
  */
17
-class ConfigurationException extends DatabaseException {
17
+class ConfigurationException extends DatabaseException {
18 18
 
19
-	public function __construct( $message = 'The specified database configuration is invalid', $code = 0, \Exception $previous = null ) {
19
+	public function __construct( $message = 'The specified database configuration is invalid', $code = 0, \Exception $previous = null ) {
20 20
 		parent::__construct($message, $code, $previous);
21 21
 	}
22 22
 
Please login to merge, or discard this patch.
src/exceptions/ConnectionException.php 1 patch
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,9 +14,9 @@
 block discarded – undo
14 14
 /**
15 15
  * Thrown if a database connection could not be established.
16 16
  */
17
-class ConnectionException extends DatabaseException {
17
+class ConnectionException extends DatabaseException {
18 18
 
19
-	public function __construct( $message = 'An error occured attempting to connect to the database', $code = 0, \Exception $previous = null ) {
19
+	public function __construct( $message = 'An error occured attempting to connect to the database', $code = 0, \Exception $previous = null ) {
20 20
 		parent::__construct($message, $code, $previous);
21 21
 	}
22 22
 
Please login to merge, or discard this patch.
src/exceptions/DatabaseException.php 1 patch
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 /**
15 15
  * Base database exception.
16 16
  */
17
-class DatabaseException extends \Exception {
17
+class DatabaseException extends \Exception {
18 18
 
19 19
 	/**
20 20
 	 * https://bugs.php.net/bug.php?id=51742
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 */
23 23
 	protected $code;
24 24
 
25
-	public function __construct( $message = 'An unknown database error occured', $code = 0, \Exception $previous = null ) {
25
+	public function __construct( $message = 'An unknown database error occured', $code = 0, \Exception $previous = null ) {
26 26
 		parent::__construct($message, (int) $code, $previous);
27 27
 		$this->code = $code;
28 28
 	}
Please login to merge, or discard this patch.