Completed
Push — test ( 3a08db...090bc9 )
by Temitope
02:35
created
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/Database/DatabaseConnection.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -24,11 +24,11 @@  discard block
 block discarded – undo
24 24
 	{
25 25
 		self::loadEnv(); // load the environment variables
26 26
 
27
-		$this->databaseName     =  getenv('databaseName');
28
-		$this->databaseHost     =  getenv('databaseHost');
29
-		$this->databaseDriver   =  getenv('databaseDriver');
30
-		$this->databaseUsername =  getenv('databaseUsername');
31
-		$this->databasePassword =  getenv('databasePassword');
27
+		$this->databaseName     = getenv('databaseName');
28
+		$this->databaseHost     = getenv('databaseHost');
29
+		$this->databaseDriver   = getenv('databaseDriver');
30
+		$this->databaseUsername = getenv('databaseUsername');
31
+		$this->databasePassword = getenv('databasePassword');
32 32
 
33 33
 		try {
34 34
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 			];
41 41
 			parent::__construct($this->getDatabaseDriver(), $this->databaseUsername, $this->databasePassword, $options);
42 42
 
43
-			} catch(PDOException $e) {
43
+			} catch (PDOException $e) {
44 44
 
45 45
 			return $e->getMessage();
46 46
 		}
@@ -61,21 +61,21 @@  discard block
 block discarded – undo
61 61
 			case 'mysql':
62 62
 
63 63
 				// Set DSN
64
-				$dsn = 'mysql:host='.$this->databaseHost.';dbname='. $this->databaseName;
64
+				$dsn = 'mysql:host='.$this->databaseHost.';dbname='.$this->databaseName;
65 65
 				break;
66 66
 			case 'sqlite':
67 67
 
68 68
 				// Set DSN
69
-				$dsn = 'sqlite:host='.$this->databaseHost.';dbname='. $this->databaseName;
69
+				$dsn = 'sqlite:host='.$this->databaseHost.';dbname='.$this->databaseName;
70 70
 				break;
71 71
 			case 'pgsql':
72 72
 
73 73
 				// Set DSN
74
-				$dsn = 'pgsqlsql:host='.$this->databaseHost.';dbname='. $this->databaseName;
74
+				$dsn = 'pgsqlsql:host='.$this->databaseHost.';dbname='.$this->databaseName;
75 75
 				break;
76 76
 			default:
77 77
 				// Set DSN
78
-				$dsn = 'mysql:host='.$this->databaseHost.';dbname='. $this->databaseName;
78
+				$dsn = 'mysql:host='.$this->databaseHost.';dbname='.$this->databaseName;
79 79
 		}
80 80
 		return $dsn;
81 81
 	}
Please login to merge, or discard this patch.
src/Database/DatabaseHelper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 			$conn = $this->dbConn;
36 36
 		}
37 37
 		$sql = 'CREATE TABLE IF NOT EXISTS '.$tableName.'(';
38
-		$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 ) )';
38
+		$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 ) )';
39 39
 
40 40
 		return $conn->exec($sql);
41 41
 
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,10 +40,10 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	public function create($associative1DArray, $tableName, $dbConn = Null)
42 42
 	{
43
-		$unexpectedFields = self::checkIfMagicSetterContainsIsSameAsClassModel($this->getColumnNames($this->model, $this->dbConnection),$associative1DArray);
43
+		$unexpectedFields = self::checkIfMagicSetterContainsIsSameAsClassModel($this->getColumnNames($this->model, $this->dbConnection), $associative1DArray);
44 44
 
45 45
 		if (count($unexpectedFields) > 0) {
46
-			throw TableFieldUndefinedException::fieldsNotDefinedException($unexpectedFields,"needs to be created as table field");
46
+			throw TableFieldUndefinedException::fieldsNotDefinedException($unexpectedFields, "needs to be created as table field");
47 47
 		}
48 48
 		if ($this->findAndWhere(['alias' => $associative1DArray['alias']], $this->model, $this->dbConnection)) {
49 49
 			throw NoRecordInsertionException::checkNoRecordAddedException("Insertion Error: Record already exist");
@@ -61,17 +61,17 @@  discard block
 block discarded – undo
61 61
 	private function  insertRecord($dbConn, $tableName, $associative1DArray) {
62 62
 
63 63
 		$insertQuery = 'INSERT INTO '.$tableName;
64
-		$TableValues = implode(',',array_keys($associative1DArray));
64
+		$TableValues = implode(',', array_keys($associative1DArray));
65 65
 		foreach ($associative1DArray as $field => $value) {
66 66
 
67 67
 			$FormValues[] = "'".trim(addslashes($value))."'";
68 68
 		}
69 69
 		$splittedTableValues = implode(',', $FormValues);
70
-		$insertQuery.= ' ('.$TableValues.')';
71
-		$insertQuery.= ' VALUES ('.$splittedTableValues.')';
70
+		$insertQuery .= ' ('.$TableValues.')';
71
+		$insertQuery .= ' VALUES ('.$splittedTableValues.')';
72 72
 		$executeQuery = $dbConn->exec($insertQuery);
73 73
 
74
-		return $executeQuery ? : false;
74
+		return $executeQuery ?: false;
75 75
 	}
76 76
 
77 77
 	/*
@@ -88,13 +88,13 @@  discard block
 block discarded – undo
88 88
 
89 89
 		$updateSql = "UPDATE `$tableName` SET ";
90 90
 		unset($associative1DArray['id']);
91
-		$unexpectedFields = self::checkIfMagicSetterContainsIsSameAsClassModel($this->getColumnNames($this->model, $this->dbConnection),$associative1DArray);
91
+		$unexpectedFields = self::checkIfMagicSetterContainsIsSameAsClassModel($this->getColumnNames($this->model, $this->dbConnection), $associative1DArray);
92 92
 
93 93
 		if (count($unexpectedFields) > 0) {
94 94
 			throw TableFieldUndefinedException::fieldsNotDefinedException($unexpectedFields, "needs to be created as table field");
95 95
 		}
96 96
 
97
-		foreach($associative1DArray as $field => $value) {
97
+		foreach ($associative1DArray as $field => $value) {
98 98
 			$sql .= "`$field` = '$value'".",";
99 99
 		}
100 100
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 		$stmt = $dbConn->prepare($updateSql);
107 107
 		$boolResponse = $stmt->execute();
108 108
 
109
-		return $boolResponse ?  : false;
109
+		return $boolResponse ?: false;
110 110
 	}
111 111
 
112 112
 	/**
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 		if (is_null($dbConn)) {
122 122
 			$dbConn = new DatabaseConnection();
123 123
 		}
124
-		$sql = $id  ? 'SELECT * FROM '.$tableName.' WHERE id = '.$id : 'SELECT * FROM '.$tableName;
124
+		$sql = $id ? 'SELECT * FROM '.$tableName.' WHERE id = '.$id : 'SELECT * FROM '.$tableName;
125 125
 
126 126
 		try {
127 127
 			$stmt = $dbConn->prepare($sql);
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 		}
134 134
 		$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
135 135
 
136
-		foreach($results as $result) {
136
+		foreach ($results as $result) {
137 137
 			array_push($tableData, $result);
138 138
 		}
139 139
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 		$sql = 'DELETE FROM '.$tableName.' WHERE id = '.$id;
154 154
 		$boolResponse = $dbConn->exec($sql);
155 155
 
156
-		return $boolResponse ? : false;
156
+		return $boolResponse ?: false;
157 157
 	}
158 158
 
159 159
 	/**
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 		$unexpectedFields = [];
168 168
 
169 169
 		foreach ($userSetterArray as $key => $val) {
170
-			if (!in_array($key,$tableColumn)) {
170
+			if (!in_array($key, $tableColumn)) {
171 171
 
172 172
 				$unexpectedFields[] = $key;
173 173
 			}
@@ -182,9 +182,9 @@  discard block
 block discarded – undo
182 182
 	 */
183 183
 	public function prepareUpdateQuery($sql)
184 184
 	{
185
-		$splittedQuery = explode(",",$sql);
185
+		$splittedQuery = explode(",", $sql);
186 186
 		array_pop($splittedQuery);
187
-		$mergeData = implode(",",$splittedQuery);
187
+		$mergeData = implode(",", $splittedQuery);
188 188
 
189 189
 		return $mergeData;
190 190
 	}
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 			$statement = $dbConn->prepare($sql);
210 210
 			$statement->execute();
211 211
 			$returnedRowNumbers = $statement->rowCount();
212
-			return $returnedRowNumbers  ? true : false;
212
+			return $returnedRowNumbers ? true : false;
213 213
 		}
214 214
 
215 215
 		throw EmptyArrayException::checkEmptyArrayException("Array Expected: parameter passed to this function is not an array");
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 		$stmt->execute();
236 236
 		$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
237 237
 
238
-		foreach($results as $result) {
238
+		foreach ($results as $result) {
239 239
 			array_push($tableFields, $result['Field']);
240 240
 		}
241 241
 			return $tableFields;
Please login to merge, or discard this patch.