Completed
Push — test ( bfbcaf...37f792 )
by Temitope
02:32
created
src/Database/DatabaseConnection.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -29,11 +29,11 @@  discard block
 block discarded – undo
29 29
 
30 30
 		$this->databaseHandle   = $this->connect(); // database connection handle
31 31
 
32
-		$this->databaseName     =  getenv('databaseName');
33
-		$this->databaseHost     =  getenv('databaseHost');
34
-		$this->databaseDriver   =  getenv('databaseDriver');
35
-		$this->databaseUsername =  getenv('databaseUsername');
36
-		$this->databasePassword =  getenv('databasePassword');
32
+		$this->databaseName     = getenv('databaseName');
33
+		$this->databaseHost     = getenv('databaseHost');
34
+		$this->databaseDriver   = getenv('databaseDriver');
35
+		$this->databaseUsername = getenv('databaseUsername');
36
+		$this->databasePassword = getenv('databasePassword');
37 37
 	}
38 38
 
39 39
 	/**
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
 			$databaseHandle = new PDO($this->getDatabaseDriver(), $this->databaseUsername, $this->databasePassword, $options);
56 56
 
57
-		} catch(PDOException $e) {
57
+		} catch (PDOException $e) {
58 58
 
59 59
 			return $e->getMessage();
60 60
 
@@ -78,21 +78,21 @@  discard block
 block discarded – undo
78 78
 			case 'mysql':
79 79
 
80 80
 				// Set DSN
81
-				$dsn = 'mysql:host='.    $this->databaseHost. ';dbname='. $this->databaseName;
81
+				$dsn = 'mysql:host='.$this->databaseHost.';dbname='.$this->databaseName;
82 82
 				break;
83 83
 			case 'sqlite':
84 84
 
85 85
 				// Set DSN
86
-				$dsn = 'sqlite:host='.   $this->databaseHost. ';dbname='. $this->databaseName;
86
+				$dsn = 'sqlite:host='.$this->databaseHost.';dbname='.$this->databaseName;
87 87
 				break;
88 88
 			case 'pgsql':
89 89
 
90 90
 				// Set DSN
91
-				$dsn = 'pgsqlsql:host='. $this->databaseHost. ';dbname='. $this->databaseName;
91
+				$dsn = 'pgsqlsql:host='.$this->databaseHost.';dbname='.$this->databaseName;
92 92
 				break;
93 93
 			default:
94 94
 				// Set DSN
95
-				$dsn = 'mysql:host='.    $this->databaseHost. ';dbname='. $this->databaseName;
95
+				$dsn = 'mysql:host='.$this->databaseHost.';dbname='.$this->databaseName;
96 96
 		}
97 97
 		return $dsn;
98 98
 	}
Please login to merge, or discard this patch.
src/Database/DatabaseHelper.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
 			$sql = 'CREATE TABLE IF NOT EXISTS '.$tableName.'(';
40 40
 
41
-			$sql.= ' id INT( 11 ) AUTO_INCREMENT PRIMARY KEY, name VARCHAR( 100 ), gender VARCHAR( 10 ), alias VARCHAR( 150 ) NOT NULL, class VARCHAR( 150 ), stack VARCHAR( 50 ) )';
41
+			$sql .= ' id INT( 11 ) AUTO_INCREMENT PRIMARY KEY, name VARCHAR( 100 ), gender VARCHAR( 10 ), alias VARCHAR( 150 ) NOT NULL, class VARCHAR( 150 ), stack VARCHAR( 50 ) )';
42 42
 
43 43
 			return $conn->exec($sql);
44 44
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 * @param $table
54 54
 	 * @return array
55 55
 	 */
56
-	public function getColumnNames($table, $conn = Null){
56
+	public function getColumnNames($table, $conn = Null) {
57 57
 
58 58
 		$tableFields = [];
59 59
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
 			$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
74 74
 
75
-			foreach($results as $result) {
75
+			foreach ($results as $result) {
76 76
 				array_push($tableFields, $result['Field']);
77 77
 			}
78 78
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 
81 81
 		} catch (PDOException $e) {
82 82
 
83
-			trigger_error('Could not connect to MySQL database. ' . $e->getMessage() , E_USER_ERROR);
83
+			trigger_error('Could not connect to MySQL database. '.$e->getMessage(), E_USER_ERROR);
84 84
 		}
85 85
 	}
86 86
 
Please login to merge, or discard this patch.
src/Helper/Inflector.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
 			'sex' => 'sexes',
75 75
 			'move' => 'moves');
76 76
 		$lowercased_word = strtolower($word);
77
-		foreach ($uncountable as $_uncountable){
78
-			if(substr($lowercased_word,(-1*strlen($_uncountable))) == $_uncountable){
77
+		foreach ($uncountable as $_uncountable) {
78
+			if (substr($lowercased_word, (-1*strlen($_uncountable))) == $_uncountable) {
79 79
 				return $word;
80 80
 			}
81 81
 		}
82
-		foreach ($irregular as $_plural=> $_singular){
82
+		foreach ($irregular as $_plural=> $_singular) {
83 83
 			if (preg_match('/('.$_plural.')$/i', $word, $arr)) {
84
-				return preg_replace('/('.$_plural.')$/i', substr($arr[0],0,1).substr($_singular,1), $word);
84
+				return preg_replace('/('.$_plural.')$/i', substr($arr[0], 0, 1).substr($_singular, 1), $word);
85 85
 			}
86 86
 		}
87 87
 		foreach ($plural as $rule => $replacement) {
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
 	public function singularize($word)
103 103
 	{
104
-		$singular = array (
104
+		$singular = array(
105 105
 			'/(quiz)zes$/i'             => "$1",
106 106
 			'/(matr)ices$/i'            => "$1ix",
107 107
 			'/(vert|ind)ices$/i'        => "$1ex",
@@ -139,14 +139,14 @@  discard block
 block discarded – undo
139 139
 			'sex' => 'sexes',
140 140
 			'move' => 'moves');
141 141
 		$lowercased_word = strtolower($word);
142
-		foreach ($uncountable as $_uncountable){
143
-			if(substr($lowercased_word,(-1*strlen($_uncountable))) == $_uncountable){
142
+		foreach ($uncountable as $_uncountable) {
143
+			if (substr($lowercased_word, (-1*strlen($_uncountable))) == $_uncountable) {
144 144
 				return $word;
145 145
 			}
146 146
 		}
147
-		foreach ($irregular as $_plural=> $_singular){
147
+		foreach ($irregular as $_plural=> $_singular) {
148 148
 			if (preg_match('/('.$_singular.')$/i', $word, $arr)) {
149
-				return preg_replace('/('.$_singular.')$/i', substr($arr[0],0,1).substr($_plural,1), $word);
149
+				return preg_replace('/('.$_singular.')$/i', substr($arr[0], 0, 1).substr($_plural, 1), $word);
150 150
 			}
151 151
 		}
152 152
 		foreach ($singular as $rule => $replacement) {
Please login to merge, or discard this patch.
src/Exceptions/NoRecordInsertionException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
  * @license  <https://opensource.org/license/MIT> MIT
7 7
  */
8 8
 
9
-namespace Laztopaz\potatoORM	;
9
+namespace Laztopaz\potatoORM;
10 10
 
11 11
 use Exception;
12 12
 
Please login to merge, or discard this patch.
src/Exceptions/TableFieldUndefinedException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 
18 18
 		$splittedArray = implode(",", $fieldsNotDefined);
19 19
 
20
-		return new static ($splittedArray . "  " . $message);
20
+		return new static ($splittedArray."  ".$message);
21 21
 	}
22 22
 
23 23
 }
24 24
\ No newline at end of file
Please login to merge, or discard this patch.
src/Database/DatabaseHandler.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	public function create($associative1DArray, $tableName, $dbConn = Null)
42 42
 	{
43
-		$unexpectedFields = self::checkIfMagicSetterContainsIsSameAsClassModel($this->tableFields,$associative1DArray);
43
+		$unexpectedFields = self::checkIfMagicSetterContainsIsSameAsClassModel($this->tableFields, $associative1DArray);
44 44
 
45 45
 		if (count($unexpectedFields) > 0)
46 46
 		{
47
-			throw TableFieldUndefinedException::fieldsNotDefinedException($unexpectedFields,"needs to be created as table field");
47
+			throw TableFieldUndefinedException::fieldsNotDefinedException($unexpectedFields, "needs to be created as table field");
48 48
 		}
49 49
 
50 50
 		unset($this->tableFields[0]);
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
 		$insertQuery = 'INSERT INTO '.$tableName;
59 59
 
60
-		$TableValues = implode(',',array_keys($associative1DArray));
60
+		$TableValues = implode(',', array_keys($associative1DArray));
61 61
 
62 62
 		foreach ($associative1DArray as $field => $value) {
63 63
 
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
 		}
66 66
 		$splittedTableValues = implode(',', $FormValues);
67 67
 
68
-		$insertQuery.= ' ('.$TableValues.')';
68
+		$insertQuery .= ' ('.$TableValues.')';
69 69
 
70
-		$insertQuery.= ' VALUES ('.$splittedTableValues.')';
70
+		$insertQuery .= ' VALUES ('.$splittedTableValues.')';
71 71
 
72 72
 		$executeQuery = $dbConn->exec($insertQuery);
73 73
 
74
-		return $executeQuery ? : false;
74
+		return $executeQuery ?: false;
75 75
 	}
76 76
 
77 77
 	/*
@@ -90,19 +90,19 @@  discard block
 block discarded – undo
90 90
 
91 91
 		unset($associative1DArray['id']);
92 92
 
93
-		$unexpectedFields = self::checkIfMagicSetterContainsIsSameAsClassModel($this->tableFields,$associative1DArray);
93
+		$unexpectedFields = self::checkIfMagicSetterContainsIsSameAsClassModel($this->tableFields, $associative1DArray);
94 94
 
95 95
 		if (count($unexpectedFields) > 0) {
96 96
 
97
-			throw TableFieldUndefinedException::fieldsNotDefinedException($unexpectedFields,"needs to be created as table field");
97
+			throw TableFieldUndefinedException::fieldsNotDefinedException($unexpectedFields, "needs to be created as table field");
98 98
 		}
99 99
 
100
-		foreach($associative1DArray as $field => $value)
100
+		foreach ($associative1DArray as $field => $value)
101 101
 		{
102 102
 			$sql = "`$field` = '$value'".",";
103 103
 		}
104 104
 
105
-		$updateSql.= $this->prepareUpdateQuery($sql);
105
+		$updateSql .= $this->prepareUpdateQuery($sql);
106 106
 
107 107
 		foreach ($updateParams as $key => $val) {
108 108
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 
114 114
 		$boolResponse = $stmt->execute();
115 115
 
116
-		return $boolResponse ?  : false;
116
+		return $boolResponse ?: false;
117 117
 	}
118 118
 
119 119
 	/**
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 			$dbConn = $dhl->connect();
133 133
 		}
134 134
 
135
-		$sql = $id  ? 'SELECT * FROM '.$tableName.' WHERE id = '.$id : 'SELECT * FROM '.$tableName;
135
+		$sql = $id ? 'SELECT * FROM '.$tableName.' WHERE id = '.$id : 'SELECT * FROM '.$tableName;
136 136
 
137 137
 		try {
138 138
 			$stmt = $dbConn->prepare($sql);
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 		}
147 147
 		$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
148 148
 
149
-		foreach($results as $result) {
149
+		foreach ($results as $result) {
150 150
 
151 151
 			array_push($tableData, $result);
152 152
 		}
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 
174 174
 		$boolResponse = $dbConn->exec($sql);
175 175
 
176
-		return $boolResponse ? : false;
176
+		return $boolResponse ?: false;
177 177
 	}
178 178
 
179 179
 	/**
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 
189 189
 		foreach ($userSetterArray as $key => $val)
190 190
 		{
191
-			if (!in_array($key,$tableColumn)) {
191
+			if (!in_array($key, $tableColumn)) {
192 192
 
193 193
 				$unexpectedFields[] = $key;
194 194
 			}
@@ -204,11 +204,11 @@  discard block
 block discarded – undo
204 204
 	 */
205 205
 	private function prepareUpdateQuery($sql)
206 206
 	{
207
-		$splittedQuery = explode(",",$sql);
207
+		$splittedQuery = explode(",", $sql);
208 208
 
209 209
 		array_pop($splittedQuery);
210 210
 
211
-		$mergeData = implode(",",$splittedQuery);
211
+		$mergeData = implode(",", $splittedQuery);
212 212
 
213 213
 		return $mergeData;
214 214
 	}
Please login to merge, or discard this patch.