Completed
Push — test ( 719145...2ec062 )
by Temitope
02:38
created
src/Model/BaseModel.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	/**
120 120
 	 * This method find a record by id
121 121
 	 * @params int id
122
-	 * @return Object
122
+	 * @return BaseClass
123 123
 	 * @throws NoArgumentPassedToFunctionException
124 124
 	 */
125 125
 	public static function find($id)
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	/**
172 172
 	 * This method return the current class name
173 173
 	 * $params void
174
-	 * @return classname
174
+	 * @return string|false
175 175
 	 */
176 176
 	public static function getClassName()
177 177
 	{
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,6 @@
 block discarded – undo
14 14
 use Laztopaz\potatoORM\NoRecordFoundException;
15 15
 use Laztopaz\potatoORM\NoRecordInsertionException;
16 16
 use Laztopaz\potatoORM\NullArgumentPassedToFunction;
17
-use Laztopaz\potatoORM\WrongArgumentException;
18 17
 use Laztopaz\potatoORM\NoArgumentPassedToFunctionException;
19 18
 use Laztopaz\potatoORM\EmptyArrayException;
20 19
 
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/Database/DatabaseConnection.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
 class DatabaseConnection extends \PDO
16 16
 {
17 17
 	private $databaseName;
18
-    private $databaseHost;
18
+	private $databaseHost;
19 19
 	private $databaseDriver;
20
-    private $databaseUsername;
20
+	private $databaseUsername;
21 21
 	private $databasePassword;
22 22
 	private $databaseHandle;
23 23
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 
105 105
 			//$dotenv = new Dotenv($_SERVER['DOCUMENT_ROOT']);
106 106
 			$dotenv = new Dotenv(__DIR__.'/../../');
107
-		    $dotenv->load();
107
+			$dotenv->load();
108 108
 		}
109 109
 
110 110
 	}
Please login to merge, or discard this 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/DatabaseHandler.php 3 patches
Doc Comments   +10 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,6 +22,7 @@  discard block
 block discarded – undo
22 22
 
23 23
 	/**
24 24
 	 * This is a constructor; a default method  that will be called automatically during class instantiation
25
+	 * @param string|false $modelClassName
25 26
 	 */
26 27
 	public function __construct($modelClassName, $dbConn = Null)
27 28
 	{
@@ -40,6 +41,7 @@  discard block
 block discarded – undo
40 41
 	/**
41 42
 	 * This method create a record and store it in a table row
42 43
 	 * @params associative array, string tablename
44
+	 * @param string|false $tableName
43 45
 	 * @return boolean true or false
44 46
 	 */
45 47
 	public function create($associative1DArray, $tableName, $dbConn = Null)
@@ -81,6 +83,10 @@  discard block
 block discarded – undo
81 83
 	 * @params: $updateParams, $tableName, $associative1DArray
82 84
 	 * @return boolean true or false
83 85
 	 */
86
+
87
+	/**
88
+	 * @param string|false $tableName
89
+	 */
84 90
 	public function update(array $updateParams, $tableName, $associative1DArray, $dbConn = Null)
85 91
 	{
86 92
 		$sql = "";
@@ -124,6 +130,7 @@  discard block
 block discarded – undo
124 130
 	/**
125 131
 	 * This method retrieves record from a table
126 132
 	 * @params int id, string tableName
133
+	 * @param string|false $tableName
127 134
 	 * @return array
128 135
 	 */
129 136
 	public static function read($id, $tableName, $dbConn = Null)
@@ -161,6 +168,7 @@  discard block
 block discarded – undo
161 168
 	/**
162 169
 	 * This method deletes a record  from a table row
163 170
 	 * @params int id, string tableName
171
+	 * @param string|false $tableName
164 172
 	 * @return boolean true or false
165 173
 	 */
166 174
 	public static function delete($id, $tableName, $dbConn = Null)
@@ -201,7 +209,7 @@  discard block
 block discarded – undo
201 209
 
202 210
 	/**
203 211
 	 * This method returns sql query
204
-	 * @param $sql
212
+	 * @param string $sql
205 213
 	 * @return string
206 214
 	 */
207 215
 	private function prepareUpdateQuery($sql)
@@ -254,6 +262,7 @@  discard block
 block discarded – undo
254 262
 	 * This method returns column fields of a particular table
255 263
 	 * @param $table
256 264
 	 * @param $conn
265
+	 * @param DatabaseConnection $dbConn
257 266
 	 * @return array
258 267
 	 */
259 268
 	public function getColumnNames($table, $dbConn = Null){
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,6 @@
 block discarded – undo
9 9
 namespace Laztopaz\potatoORM;
10 10
 
11 11
 use PDO;
12
-use Laztopaz\potatoORM\DatabaseHelper;
13 12
 use Laztopaz\potatoORM\TableFieldUndefinedException;
14 13
 use Laztopaz\potatoORM\EmptyArrayException;
15 14
 
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 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->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 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->getColumnNames($this->model, $this->dbConnection)[0]);
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
 		$insertQuery = 'INSERT INTO '.$tableName;
57 57
 
58
-		$TableValues = implode(',',array_keys($associative1DArray));
58
+		$TableValues = implode(',', array_keys($associative1DArray));
59 59
 
60 60
 		foreach ($associative1DArray as $field => $value) {
61 61
 
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
 		}
64 64
 		$splittedTableValues = implode(',', $FormValues);
65 65
 
66
-		$insertQuery.= ' ('.$TableValues.')';
66
+		$insertQuery .= ' ('.$TableValues.')';
67 67
 
68
-		$insertQuery.= ' VALUES ('.$splittedTableValues.')';
68
+		$insertQuery .= ' VALUES ('.$splittedTableValues.')';
69 69
 
70 70
 		$executeQuery = $dbConn->exec($insertQuery);
71 71
 
72
-		return $executeQuery ? : false;
72
+		return $executeQuery ?: false;
73 73
 	}
74 74
 
75 75
 	/*
@@ -90,15 +90,15 @@  discard block
 block discarded – undo
90 90
 
91 91
 		unset($associative1DArray['id']);
92 92
 
93
-		$unexpectedFields = self::checkIfMagicSetterContainsIsSameAsClassModel($this->getColumnNames($this->model, $this->dbConnection),$associative1DArray);
93
+		$unexpectedFields = self::checkIfMagicSetterContainsIsSameAsClassModel($this->getColumnNames($this->model, $this->dbConnection), $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 100
 
101
-		foreach($associative1DArray as $field => $value)
101
+		foreach ($associative1DArray as $field => $value)
102 102
 		{
103 103
 			$sql .= "`$field` = '$value'".",";
104 104
 		}
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 
115 115
 		$boolResponse = $stmt->execute();
116 116
 
117
-		return $boolResponse ?  : false;
117
+		return $boolResponse ?: false;
118 118
 	}
119 119
 
120 120
 	/**
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 
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
 		}
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
 		$boolResponse = $dbConn->exec($sql);
173 173
 
174
-		return $boolResponse ? : false;
174
+		return $boolResponse ?: false;
175 175
 	}
176 176
 
177 177
 	/**
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 
187 187
 		foreach ($userSetterArray as $key => $val)
188 188
 		{
189
-			if (!in_array($key,$tableColumn)) {
189
+			if (!in_array($key, $tableColumn)) {
190 190
 
191 191
 				$unexpectedFields[] = $key;
192 192
 			}
@@ -202,11 +202,11 @@  discard block
 block discarded – undo
202 202
 	 */
203 203
 	public function prepareUpdateQuery($sql)
204 204
 	{
205
-		$splittedQuery = explode(",",$sql);
205
+		$splittedQuery = explode(",", $sql);
206 206
 
207 207
 		array_pop($splittedQuery);
208 208
 
209
-		$mergeData = implode(",",$splittedQuery);
209
+		$mergeData = implode(",", $splittedQuery);
210 210
 
211 211
 		return $mergeData;
212 212
 	}
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 
241 241
 			$returnedRowNumbers = $statement->rowCount();
242 242
 
243
-			return $returnedRowNumbers  ? true : false;
243
+			return $returnedRowNumbers ? true : false;
244 244
 		}
245 245
 
246 246
 		throw EmptyArrayException::checkEmptyArrayException("Array Expected: parameter passed to this function is not an array");
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 
268 268
 		$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
269 269
 
270
-		foreach($results as $result) {
270
+		foreach ($results as $result) {
271 271
 
272 272
 			array_push($tableFields, $result['Field']);
273 273
 		}
Please login to merge, or discard this patch.
src/Database/DatabaseHelper.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,6 @@
 block discarded – undo
8 8
 
9 9
 namespace Laztopaz\potatoORM;
10 10
 
11
-use PDO;
12 11
 use Laztopaz\potatoORM\TableNotCreatedException;
13 12
 
14 13
 class DatabaseHelper {
Please login to merge, or discard this 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.