@@ -81,15 +81,15 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | $lowercased_word = strtolower($word); |
| 83 | 83 | |
| 84 | - foreach ($uncountable as $_uncountable){ |
|
| 85 | - if(substr($lowercased_word,(-1*strlen($_uncountable))) == $_uncountable){ |
|
| 84 | + foreach ($uncountable as $_uncountable) { |
|
| 85 | + if (substr($lowercased_word, (-1*strlen($_uncountable))) == $_uncountable) { |
|
| 86 | 86 | return $word; |
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - foreach ($irregular as $_plural=> $_singular){ |
|
| 90 | + foreach ($irregular as $_plural=> $_singular) { |
|
| 91 | 91 | if (preg_match('/('.$_plural.')$/i', $word, $arr)) { |
| 92 | - return preg_replace('/('.$_plural.')$/i', substr($arr[0],0,1).substr($_singular,1), $word); |
|
| 92 | + return preg_replace('/('.$_plural.')$/i', substr($arr[0], 0, 1).substr($_singular, 1), $word); |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | public function singularize($word) |
| 113 | 113 | { |
| 114 | - $singular = array ( |
|
| 114 | + $singular = array( |
|
| 115 | 115 | '/(quiz)zes$/i' => "$1", |
| 116 | 116 | '/(matr)ices$/i' => "$1ix", |
| 117 | 117 | '/(vert|ind)ices$/i' => "$1ex", |
@@ -152,15 +152,15 @@ discard block |
||
| 152 | 152 | 'move' => 'moves'); |
| 153 | 153 | |
| 154 | 154 | $lowercased_word = strtolower($word); |
| 155 | - foreach ($uncountable as $_uncountable){ |
|
| 156 | - if(substr($lowercased_word,(-1*strlen($_uncountable))) == $_uncountable){ |
|
| 155 | + foreach ($uncountable as $_uncountable) { |
|
| 156 | + if (substr($lowercased_word, (-1*strlen($_uncountable))) == $_uncountable) { |
|
| 157 | 157 | return $word; |
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - foreach ($irregular as $_plural=> $_singular){ |
|
| 161 | + foreach ($irregular as $_plural=> $_singular) { |
|
| 162 | 162 | if (preg_match('/('.$_singular.')$/i', $word, $arr)) { |
| 163 | - return preg_replace('/('.$_singular.')$/i', substr($arr[0],0,1).substr($_plural,1), $word); |
|
| 163 | + return preg_replace('/('.$_singular.')$/i', substr($arr[0], 0, 1).substr($_plural, 1), $word); |
|
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | |
@@ -25,6 +25,6 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | public function errorMessage() |
| 27 | 27 | { |
| 28 | - return "Error: " . $this->getMessage(); |
|
| 28 | + return "Error: ".$this->getMessage(); |
|
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | \ No newline at end of file |
@@ -25,6 +25,6 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | public function errorMessage() |
| 27 | 27 | { |
| 28 | - return "Error: " . $this->getMessage(); |
|
| 28 | + return "Error: ".$this->getMessage(); |
|
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | \ No newline at end of file |
@@ -25,6 +25,6 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | public function errorMessage() |
| 27 | 27 | { |
| 28 | - return "Error: " . $this->getMessage(); |
|
| 28 | + return "Error: ".$this->getMessage(); |
|
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | \ No newline at end of file |
@@ -25,6 +25,6 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | public function errorMessage() |
| 27 | 27 | { |
| 28 | - return "Error: " . $this->getMessage(); |
|
| 28 | + return "Error: ".$this->getMessage(); |
|
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | \ No newline at end of file |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | parent::__construct($this->mysqlConnectionString(), $this->user, $this->password); |
| 49 | 49 | } |
| 50 | - elseif($this->driver === 'sqlite') |
|
| 50 | + elseif ($this->driver === 'sqlite') |
|
| 51 | 51 | { |
| 52 | 52 | parent::__construct($this->sqlitConnectionString()); |
| 53 | 53 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | protected function pgsqlConnectionString() |
| 65 | 65 | { |
| 66 | - return $this->driver . ':host=' . $this->host . ';port=' . $this->port . ';dbname=' . $this->dbname . ';user=' . $this->user . ';password=' . $this->password; |
|
| 66 | + return $this->driver.':host='.$this->host.';port='.$this->port.';dbname='.$this->dbname.';user='.$this->user.';password='.$this->password; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | protected function mysqlConnectionString() |
| 75 | 75 | { |
| 76 | - return $this->driver . ':host=' . $this->host . ';dbname=' . $this->dbname . ';charset=utf8mb4'; |
|
| 76 | + return $this->driver.':host='.$this->host.';dbname='.$this->dbname.';charset=utf8mb4'; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | protected function sqlitConnectionString() |
| 85 | 85 | { |
| 86 | - return $this->driver . ':' . $this->sqlitePath; |
|
| 86 | + return $this->driver.':'.$this->sqlitePath; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | protected function loadEnv() |
| 93 | 93 | { |
| 94 | - if( ! getenv("APP_ENV")) |
|
| 94 | + if ( ! getenv("APP_ENV")) |
|
| 95 | 95 | { |
| 96 | 96 | $dotenv = new Dotenv($_SERVER['DOCUMENT_ROOT']); |
| 97 | 97 | $dotenv->load(); |
@@ -25,13 +25,13 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | * @return array |
| 27 | 27 | */ |
| 28 | - public function field($type, $fieldName, $length=NULL) |
|
| 28 | + public function field($type, $fieldName, $length = NULL) |
|
| 29 | 29 | { |
| 30 | - if($length === null){ |
|
| 31 | - $this->fieldDescription[] = $type ." ".$fieldName; |
|
| 32 | - }else |
|
| 30 | + if ($length === null) { |
|
| 31 | + $this->fieldDescription[] = $type." ".$fieldName; |
|
| 32 | + } else |
|
| 33 | 33 | { |
| 34 | - $this->fieldDescription[] = $type ." ".$fieldName." ".$length; |
|
| 34 | + $this->fieldDescription[] = $type." ".$fieldName." ".$length; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | } |
@@ -51,12 +51,12 @@ discard block |
||
| 51 | 51 | $fields = explode(" ", $fieldName); |
| 52 | 52 | |
| 53 | 53 | $constrain = $fields[0]; |
| 54 | - if(count($fields) == 2) |
|
| 54 | + if (count($fields) == 2) |
|
| 55 | 55 | { |
| 56 | - $query .= $this->$constrain($fields[1], 20) .", ".PHP_EOL; |
|
| 57 | - }else |
|
| 56 | + $query .= $this->$constrain($fields[1], 20).", ".PHP_EOL; |
|
| 57 | + } else |
|
| 58 | 58 | { |
| 59 | - $query .= $this->$constrain($fields[1], $fields[2]) .", ".PHP_EOL; |
|
| 59 | + $query .= $this->$constrain($fields[1], $fields[2]).", ".PHP_EOL; |
|
| 60 | 60 | } |
| 61 | 61 | }; |
| 62 | 62 | array_walk($this->fieldDescription, $callback); |
@@ -90,11 +90,11 @@ discard block |
||
| 90 | 90 | { |
| 91 | 91 | $sqlQuery = self::sanitizeQuery($tablename); |
| 92 | 92 | $query = $connection->prepare($sqlQuery); |
| 93 | - if($query->execute()) |
|
| 93 | + if ($query->execute()) |
|
| 94 | 94 | { |
| 95 | 95 | return true; |
| 96 | 96 | } |
| 97 | - }catch(PDOException $e){ |
|
| 97 | + } catch (PDOException $e) { |
|
| 98 | 98 | return $e->getMessage(); |
| 99 | 99 | } |
| 100 | 100 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | public function strings($value, $length) |
| 118 | 118 | { |
| 119 | - return $value ." varchar (".$length.") NOT NULL"; |
|
| 119 | + return $value." varchar (".$length.") NOT NULL"; |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -202,6 +202,6 @@ discard block |
||
| 202 | 202 | $apend = 'timestamp'; |
| 203 | 203 | break; |
| 204 | 204 | } |
| 205 | - return $value . " " . $apend . " NOT NULL"; |
|
| 205 | + return $value." ".$apend." NOT NULL"; |
|
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 | \ No newline at end of file |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | $query = $this->insertQuery(self::getTableName($connection)); |
| 96 | 96 | $statement = $connection->prepare($query); |
| 97 | - if($statement->execute()) { |
|
| 97 | + if ($statement->execute()) { |
|
| 98 | 98 | return true; |
| 99 | 99 | } |
| 100 | 100 | throw new DataAlreadyExistException(); |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | { |
| 130 | 130 | $connection = DatabaseQuery::checkConnection($dbConnection); |
| 131 | 131 | |
| 132 | - $query = $connection->prepare('DELETE FROM ' . self::getTableName($connection) . ' WHERE id = '.$value); |
|
| 132 | + $query = $connection->prepare('DELETE FROM '.self::getTableName($connection).' WHERE id = '.$value); |
|
| 133 | 133 | $query->execute(); |
| 134 | 134 | $check = $query->rowCount(); |
| 135 | 135 | if ($check) { |
@@ -94,12 +94,12 @@ discard block |
||
| 94 | 94 | $Extension = strtolower($FileParts['extension']); |
| 95 | 95 | $ValidExtensions = $this->ValidExtensions; |
| 96 | 96 | |
| 97 | - if (!$FileName) { |
|
| 97 | + if ( ! $FileName) { |
|
| 98 | 98 | $this->SetMessage("ERROR: File name is empty."); |
| 99 | 99 | return false; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - if (!$ValidExtensions) { |
|
| 102 | + if ( ! $ValidExtensions) { |
|
| 103 | 103 | $this->SetMessage("WARNING: All extensions are valid."); |
| 104 | 104 | return true; |
| 105 | 105 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | $TempFileName = $this->GetTempName(); |
| 125 | 125 | $TempFileSize = filesize($TempFileName); |
| 126 | 126 | |
| 127 | - if($MaximumFileSize == "") { |
|
| 127 | + if ($MaximumFileSize == "") { |
|
| 128 | 128 | $this->SetMessage("WARNING: There is no size restriction."); |
| 129 | 129 | return true; |
| 130 | 130 | } |
@@ -146,11 +146,11 @@ discard block |
||
| 146 | 146 | public function ValidateExistance($uploadDirectory) |
| 147 | 147 | { |
| 148 | 148 | $FileName = $this->GetFileName(); |
| 149 | - $File = $uploadDirectory . $FileName; |
|
| 149 | + $File = $uploadDirectory.$FileName; |
|
| 150 | 150 | |
| 151 | 151 | if (file_exists($File)) { |
| 152 | 152 | $this->SetMessage("Message: The file '$FileName' already exist."); |
| 153 | - $UniqueName = rand() . $FileName; |
|
| 153 | + $UniqueName = rand().$FileName; |
|
| 154 | 154 | $this->SetFileName($UniqueName); |
| 155 | 155 | $this->ValidateExistance($uploadDirectory); |
| 156 | 156 | } else { |
@@ -166,24 +166,24 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | public function ValidateDirectory($uploadDirectory) |
| 168 | 168 | { |
| 169 | - if (! $uploadDirectory) { |
|
| 169 | + if ( ! $uploadDirectory) { |
|
| 170 | 170 | $this->SetMessage("ERROR: The directory variable is empty."); |
| 171 | 171 | return false; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - if (!is_dir($uploadDirectory)) { |
|
| 174 | + if ( ! is_dir($uploadDirectory)) { |
|
| 175 | 175 | $this->SetMessage("ERROR: The directory '$uploadDirectory' does not exist."); |
| 176 | 176 | return false; |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if (!is_writable($uploadDirectory)) { |
|
| 179 | + if ( ! is_writable($uploadDirectory)) { |
|
| 180 | 180 | $this->SetMessage("ERROR: The directory '$uploadDirectory' does not writable."); |
| 181 | 181 | return false; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | if (substr($uploadDirectory, -1) != "/") { |
| 185 | 185 | $this->SetMessage("ERROR: The traling slash does not exist."); |
| 186 | - $NewDirectory = $uploadDirectory . "/"; |
|
| 186 | + $NewDirectory = $uploadDirectory."/"; |
|
| 187 | 187 | $this->SetUploadDirectory($NewDirectory); |
| 188 | 188 | $this->ValidateDirectory($uploadDirectory); |
| 189 | 189 | } else { |
@@ -202,9 +202,9 @@ discard block |
||
| 202 | 202 | $MaximumHeight = $this->MaximumHeight; |
| 203 | 203 | $TempFileName = $this->GetTempName(); |
| 204 | 204 | |
| 205 | - if($Size = @getimagesize($TempFileName)) { |
|
| 206 | - $Width = $Size[0]; //$Width is the width in pixels of the image uploaded to the server. |
|
| 207 | - $Height = $Size[1]; //$Height is the height in pixels of the image uploaded to the server. |
|
| 205 | + if ($Size = @getimagesize($TempFileName)) { |
|
| 206 | + $Width = $Size[0]; //$Width is the width in pixels of the image uploaded to the server. |
|
| 207 | + $Height = $Size[1]; //$Height is the height in pixels of the image uploaded to the server. |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | if ($Width > $MaximumWidth) { |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | |
| 324 | 324 | public function GetMessage() |
| 325 | 325 | { |
| 326 | - if (!isset($this->Message)) { |
|
| 326 | + if ( ! isset($this->Message)) { |
|
| 327 | 327 | $this->SetMessage("No Message"); |
| 328 | 328 | } |
| 329 | 329 | |