@@ -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 |
@@ -51,6 +51,7 @@ discard block |
||
| 51 | 51 | /** |
| 52 | 52 | * getTableName() |
| 53 | 53 | * |
| 54 | + * @param string $connection |
|
| 54 | 55 | * @return string |
| 55 | 56 | */ |
| 56 | 57 | public static function getTableName($connection) |
@@ -62,7 +63,7 @@ discard block |
||
| 62 | 63 | * getALL() |
| 63 | 64 | * Get all record from the database |
| 64 | 65 | * |
| 65 | - * @return object |
|
| 66 | + * @return GetData |
|
| 66 | 67 | */ |
| 67 | 68 | public function getALL($dbConnection = NULL) |
| 68 | 69 | { |
@@ -82,7 +83,7 @@ discard block |
||
| 82 | 83 | * where($data, $condition) |
| 83 | 84 | * Get data from database where $data = $condition |
| 84 | 85 | * |
| 85 | - * @return object |
|
| 86 | + * @return GetData |
|
| 86 | 87 | */ |
| 87 | 88 | public function where($data, $condition = NULL, $dbConnection = NULL) |
| 88 | 89 | { |
@@ -103,7 +104,7 @@ discard block |
||
| 103 | 104 | * find($value) |
| 104 | 105 | * Find data from database where id = $value |
| 105 | 106 | * |
| 106 | - * @return array |
|
| 107 | + * @return Model |
|
| 107 | 108 | */ |
| 108 | 109 | public static function find($value, $dbConnection = NULL) |
| 109 | 110 | { |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public function tableName() |
| 48 | 48 | { |
| 49 | - if(isset($this->table)) { |
|
| 49 | + if (isset($this->table)) { |
|
| 50 | 50 | return $this->table; |
| 51 | 51 | } |
| 52 | 52 | return null; |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | $sqlQuery = DatabaseQuery::selectAllQuery(self::getTableName($connection), self::fields()); |
| 106 | 106 | $query = $connection->prepare($sqlQuery); |
| 107 | 107 | $query->execute(); |
| 108 | - if ( $query->rowCount() ) |
|
| 108 | + if ($query->rowCount()) |
|
| 109 | 109 | { |
| 110 | 110 | return new GetData($query->fetchAll($connection::FETCH_ASSOC)); |
| 111 | 111 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | $sqlQuery = $databaseQuery->selectQuery(self::getTableName($connection), $data, $condition, $connection); |
| 127 | 127 | $query = $connection->prepare($sqlQuery); |
| 128 | 128 | $query->execute(); |
| 129 | - if ( $query->rowCount() ) |
|
| 129 | + if ($query->rowCount()) |
|
| 130 | 130 | { |
| 131 | 131 | return new GetData($query->fetchAll($connection::FETCH_ASSOC)); |
| 132 | 132 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | $sqlQuery = DatabaseQuery::selectQuery(self::getTableName($connection), ['id' => $value], NULL, $connection); |
| 147 | 147 | $query = $connection->prepare($sqlQuery); |
| 148 | 148 | $query->execute(); |
| 149 | - if ( $query->rowCount() ) |
|
| 149 | + if ($query->rowCount()) |
|
| 150 | 150 | { |
| 151 | 151 | $found = new static; |
| 152 | 152 | $found->id = $value; |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | $query = $this->insertQuery(self::getTableName($connection)); |
| 170 | 170 | $statement = $connection->prepare($query); |
| 171 | - if( $statement->execute() ) |
|
| 171 | + if ($statement->execute()) |
|
| 172 | 172 | { |
| 173 | 173 | return true; |
| 174 | 174 | } |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | |
| 189 | 189 | $updateQuery = $this->updateQuery(self::getTableName($connection)); |
| 190 | 190 | $statement = $connection->prepare($updateQuery); |
| 191 | - if( $statement->execute() ) |
|
| 191 | + if ($statement->execute()) |
|
| 192 | 192 | { |
| 193 | 193 | return true; |
| 194 | 194 | } |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | { |
| 206 | 206 | $connection = DatabaseQuery::checkConnection($dbConnection); |
| 207 | 207 | |
| 208 | - $query = $connection->prepare('DELETE FROM ' . self::getTableName($connection) . ' WHERE id = '.$value); |
|
| 208 | + $query = $connection->prepare('DELETE FROM '.self::getTableName($connection).' WHERE id = '.$value); |
|
| 209 | 209 | $query->execute(); |
| 210 | 210 | $check = $query->rowCount(); |
| 211 | 211 | if ($check) |
@@ -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(); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * @param $tablename |
| 63 | 63 | * @param $con |
| 64 | 64 | * |
| 65 | - * @return bool |
|
| 65 | + * @return boolean|null |
|
| 66 | 66 | */ |
| 67 | 67 | public function checkTableExist($table, $con=NULL) |
| 68 | 68 | { |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | /** |
| 78 | 78 | * checkTableName Return the table name |
| 79 | 79 | * |
| 80 | - * @param $tablename |
|
| 80 | + * @param string|false $tablename |
|
| 81 | 81 | * @param $con |
| 82 | 82 | * |
| 83 | 83 | * @return string |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * checkColumn Check if column exist in table |
| 99 | 99 | * |
| 100 | 100 | * @param $tableName |
| 101 | - * @param $columnName |
|
| 101 | + * @param string $columnName |
|
| 102 | 102 | * @param $con |
| 103 | 103 | * |
| 104 | 104 | * @return string |
@@ -191,6 +191,8 @@ discard block |
||
| 191 | 191 | /** |
| 192 | 192 | * selectAllQuery |
| 193 | 193 | * |
| 194 | + * @param string $tableName |
|
| 195 | + * @param string $field |
|
| 194 | 196 | * @return string |
| 195 | 197 | */ |
| 196 | 198 | public static function selectAllQuery($tableName, $field) |
@@ -226,6 +228,9 @@ discard block |
||
| 226 | 228 | /** |
| 227 | 229 | * selectQuery |
| 228 | 230 | * |
| 231 | + * @param string $tableName |
|
| 232 | + * @param string $fields |
|
| 233 | + * @param string $connection |
|
| 229 | 234 | * @return string |
| 230 | 235 | */ |
| 231 | 236 | public static function selectQuery($tableName, $fields, $data, $condition, $connection) |
@@ -253,6 +258,7 @@ discard block |
||
| 253 | 258 | /** |
| 254 | 259 | * insertQuery |
| 255 | 260 | * |
| 261 | + * @param string $tableName |
|
| 256 | 262 | * @return string |
| 257 | 263 | */ |
| 258 | 264 | public function insertQuery($tableName) |
@@ -270,6 +276,7 @@ discard block |
||
| 270 | 276 | /** |
| 271 | 277 | * updateQuery |
| 272 | 278 | * |
| 279 | + * @param string $tableName |
|
| 273 | 280 | * @return string |
| 274 | 281 | */ |
| 275 | 282 | public function updateQuery($tableName) |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | protected static function checkConnection($con) |
| 51 | 51 | { |
| 52 | - if( $con === null ) |
|
| 52 | + if ($con === null) |
|
| 53 | 53 | { |
| 54 | 54 | $con = self::connect(); |
| 55 | 55 | } |
@@ -64,11 +64,11 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | * @return bool |
| 66 | 66 | */ |
| 67 | - public function checkTableExist($table, $con=NULL) |
|
| 67 | + public function checkTableExist($table, $con = NULL) |
|
| 68 | 68 | { |
| 69 | 69 | $connection = $this->checkConnection($con); |
| 70 | 70 | $query = $connection->query("SELECT 1 FROM {$table} LIMIT 1"); |
| 71 | - if( $query !== false ) |
|
| 71 | + if ($query !== false) |
|
| 72 | 72 | { |
| 73 | 73 | return true; |
| 74 | 74 | } |
@@ -82,12 +82,12 @@ discard block |
||
| 82 | 82 | * |
| 83 | 83 | * @return string |
| 84 | 84 | */ |
| 85 | - public static function checkTableName($tableName, $con=NULL) |
|
| 85 | + public static function checkTableName($tableName, $con = NULL) |
|
| 86 | 86 | { |
| 87 | 87 | $connection = self::checkConnection($con); |
| 88 | 88 | |
| 89 | 89 | $query = $connection->query("SELECT 1 FROM {$tableName} LIMIT 1"); |
| 90 | - if( $query !== false ) |
|
| 90 | + if ($query !== false) |
|
| 91 | 91 | { |
| 92 | 92 | return $tableName; |
| 93 | 93 | } |
@@ -103,13 +103,13 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @return string |
| 105 | 105 | */ |
| 106 | - protected static function checkColumn($tableName, $columnName, $con=NULL) |
|
| 106 | + protected static function checkColumn($tableName, $columnName, $con = NULL) |
|
| 107 | 107 | { |
| 108 | 108 | $connection = self::checkConnection($con); |
| 109 | 109 | |
| 110 | 110 | $result = $connection->prepare("SELECT {$columnName} FROM {$tableName}"); |
| 111 | 111 | $result->execute(); |
| 112 | - if ( ! $result->columnCount() ) |
|
| 112 | + if ( ! $result->columnCount()) |
|
| 113 | 113 | { |
| 114 | 114 | throw new ColumnNotExistExeption(); |
| 115 | 115 | } |
@@ -152,11 +152,11 @@ discard block |
||
| 152 | 152 | $columnNames = self::getColumns($getClassVars); |
| 153 | 153 | $arraySize = count($columnNames); |
| 154 | 154 | |
| 155 | - foreach ( $columnNames as $key => $value ) |
|
| 155 | + foreach ($columnNames as $key => $value) |
|
| 156 | 156 | { |
| 157 | 157 | $counter++; |
| 158 | 158 | $insertQuery .= self::sanitize($key); |
| 159 | - if( $arraySize > $counter ) |
|
| 159 | + if ($arraySize > $counter) |
|
| 160 | 160 | $insertQuery .= ", "; |
| 161 | 161 | } |
| 162 | 162 | |
@@ -177,11 +177,11 @@ discard block |
||
| 177 | 177 | $columnNames = self::getColumns($getClassVars); |
| 178 | 178 | $arraySize = count($columnNames); |
| 179 | 179 | |
| 180 | - foreach ( $columnNames as $key => $value ) |
|
| 180 | + foreach ($columnNames as $key => $value) |
|
| 181 | 181 | { |
| 182 | 182 | $counter++; |
| 183 | - $insertQuery .= "'".self::sanitize($value) ."'"; |
|
| 184 | - if( $arraySize > $counter ) |
|
| 183 | + $insertQuery .= "'".self::sanitize($value)."'"; |
|
| 184 | + if ($arraySize > $counter) |
|
| 185 | 185 | $insertQuery .= ", "; |
| 186 | 186 | } |
| 187 | 187 | return $insertQuery; |
@@ -200,12 +200,12 @@ discard block |
||
| 200 | 200 | $updateQuery = ""; |
| 201 | 201 | $arraySize = count($data); |
| 202 | 202 | |
| 203 | - foreach ( $data as $key => $value ) |
|
| 203 | + foreach ($data as $key => $value) |
|
| 204 | 204 | { |
| 205 | 205 | $counter++; |
| 206 | 206 | $columnName = self::checkColumn($tableName, self::sanitize($key)); |
| 207 | - $updateQuery .= $columnName ." = '".self::sanitize($value)."'"; |
|
| 208 | - if ( $arraySize > $counter ) |
|
| 207 | + $updateQuery .= $columnName." = '".self::sanitize($value)."'"; |
|
| 208 | + if ($arraySize > $counter) |
|
| 209 | 209 | { |
| 210 | 210 | $updateQuery .= ", "; |
| 211 | 211 | } |
@@ -234,14 +234,14 @@ discard block |
||
| 234 | 234 | $counter = 0; |
| 235 | 235 | $arraySize = count($data); |
| 236 | 236 | |
| 237 | - foreach ( $data as $key => $value ) |
|
| 237 | + foreach ($data as $key => $value) |
|
| 238 | 238 | { |
| 239 | 239 | $counter++; |
| 240 | 240 | $columnName = self::checkColumn($tableName, self::sanitize($key)); |
| 241 | - $where .= $columnName ." = '".self::sanitize($value)."'"; |
|
| 242 | - if ( $arraySize > $counter ) |
|
| 241 | + $where .= $columnName." = '".self::sanitize($value)."'"; |
|
| 242 | + if ($arraySize > $counter) |
|
| 243 | 243 | { |
| 244 | - $where .= " " . $condition . " "; |
|
| 244 | + $where .= " ".$condition." "; |
|
| 245 | 245 | } |
| 246 | 246 | } |
| 247 | 247 | |
@@ -259,14 +259,14 @@ discard block |
||
| 259 | 259 | try |
| 260 | 260 | { |
| 261 | 261 | $arraySize = count($data); |
| 262 | - if( $arraySize > 1 && $condition == NULL) |
|
| 262 | + if ($arraySize > 1 && $condition == NULL) |
|
| 263 | 263 | { |
| 264 | 264 | $query = "Please Supply the condition"; |
| 265 | 265 | } |
| 266 | 266 | else |
| 267 | 267 | { |
| 268 | 268 | $columnName = self::whereAndClause($tableName, $data, $condition); |
| 269 | - $query = "SELECT $fields FROM $tableName WHERE $columnName"; |
|
| 269 | + $query = "SELECT $fields FROM $tableName WHERE $columnName"; |
|
| 270 | 270 | } |
| 271 | 271 | } catch (PDOException $e) { |
| 272 | 272 | $query = $e->getMessage(); |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | */ |
| 283 | 283 | public function insertQuery($tableName) |
| 284 | 284 | { |
| 285 | - $data = ( array )$this; |
|
| 285 | + $data = (array)$this; |
|
| 286 | 286 | array_shift($data); |
| 287 | 287 | |
| 288 | 288 | $columnNames = self::buildColumn($data); |
@@ -298,11 +298,11 @@ discard block |
||
| 298 | 298 | */ |
| 299 | 299 | public function updateQuery($tableName) |
| 300 | 300 | { |
| 301 | - $data = ( array ) $this; |
|
| 301 | + $data = (array)$this; |
|
| 302 | 302 | $data = array_slice($data, 2); |
| 303 | 303 | |
| 304 | 304 | $values = self::buildClause($tableName, $data); |
| 305 | - $updateQuery = "UPDATE $tableName SET {$values} WHERE id = ". self::sanitize($this->id); |
|
| 305 | + $updateQuery = "UPDATE $tableName SET {$values} WHERE id = ".self::sanitize($this->id); |
|
| 306 | 306 | |
| 307 | 307 | return $updateQuery; |
| 308 | 308 | } |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | /** |
| 63 | 63 | *@method bool ValidateExtension() returns whether the extension of file to be uploaded |
| 64 | 64 | * is allowable or not. |
| 65 | - *@return true the extension is valid. |
|
| 66 | - *@return false the extension is invalid. |
|
| 65 | + *@return boolean the extension is valid. |
|
| 66 | + *@return boolean the extension is invalid. |
|
| 67 | 67 | */ |
| 68 | 68 | public function ValidateExtension() |
| 69 | 69 | { |
@@ -95,8 +95,8 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | /** |
| 97 | 97 | *@method bool ValidateSize() returns whether the file size is acceptable. |
| 98 | - *@return true the size is smaller than the alloted value. |
|
| 99 | - *@return false the size is larger than the alloted value. |
|
| 98 | + *@return boolean the size is smaller than the alloted value. |
|
| 99 | + *@return boolean the size is larger than the alloted value. |
|
| 100 | 100 | */ |
| 101 | 101 | public function ValidateSize() |
| 102 | 102 | { |
@@ -120,8 +120,8 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | /** |
| 122 | 122 | *@method bool ValidateExistance() determins whether the file already exists. If so, rename $FileName. |
| 123 | - *@return true can never be returned as all file names must be unique. |
|
| 124 | - *@return false the file name does not exist. |
|
| 123 | + *@return null|false can never be returned as all file names must be unique. |
|
| 124 | + *@return null|false the file name does not exist. |
|
| 125 | 125 | */ |
| 126 | 126 | public function ValidateExistance() |
| 127 | 127 | { |
@@ -142,8 +142,8 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | /** |
| 144 | 144 | *@method bool ValidateDirectory() |
| 145 | - *@return true the UploadDirectory exists, writable, and has a traling slash. |
|
| 146 | - *@return false the directory was never set, does not exist, or is not writable. |
|
| 145 | + *@return null|boolean the UploadDirectory exists, writable, and has a traling slash. |
|
| 146 | + *@return null|boolean the directory was never set, does not exist, or is not writable. |
|
| 147 | 147 | */ |
| 148 | 148 | public function ValidateDirectory() |
| 149 | 149 | { |
@@ -177,8 +177,8 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | /** |
| 179 | 179 | *@method bool ValidateImage() |
| 180 | - *@return true the image is smaller than the alloted dimensions. |
|
| 181 | - *@return false the width and/or height is larger then the alloted dimensions. |
|
| 180 | + *@return boolean the image is smaller than the alloted dimensions. |
|
| 181 | + *@return boolean the width and/or height is larger then the alloted dimensions. |
|
| 182 | 182 | */ |
| 183 | 183 | public function ValidateImage() { |
| 184 | 184 | $MaximumWidth = $this->MaximumWidth; |
@@ -206,8 +206,8 @@ discard block |
||
| 206 | 206 | |
| 207 | 207 | /** |
| 208 | 208 | *@method bool UploadFile() uploads the file to the server after passing all the validations. |
| 209 | - *@return true the file was uploaded. |
|
| 210 | - *@return false the upload failed. |
|
| 209 | + *@return null|boolean the file was uploaded. |
|
| 210 | + *@return null|boolean the upload failed. |
|
| 211 | 211 | */ |
| 212 | 212 | public function uploadFile() |
| 213 | 213 | { |
@@ -251,11 +251,18 @@ discard block |
||
| 251 | 251 | |
| 252 | 252 | #Accessors and Mutators beyond this point. |
| 253 | 253 | #Siginificant documentation is not needed. |
| 254 | + |
|
| 255 | + /** |
|
| 256 | + * @param string $argv |
|
| 257 | + */ |
|
| 254 | 258 | public function SetFileName($argv) |
| 255 | 259 | { |
| 256 | 260 | $this->FileName = $argv; |
| 257 | 261 | } |
| 258 | 262 | |
| 263 | + /** |
|
| 264 | + * @param string $argv |
|
| 265 | + */ |
|
| 259 | 266 | public function SetUploadDirectory($argv) |
| 260 | 267 | { |
| 261 | 268 | $this->UploadDirectory = $argv; |
@@ -310,6 +317,9 @@ discard block |
||
| 310 | 317 | return $this->UploadDirectory; |
| 311 | 318 | } |
| 312 | 319 | |
| 320 | + /** |
|
| 321 | + * @return string |
|
| 322 | + */ |
|
| 313 | 323 | public function GetTempName() |
| 314 | 324 | { |
| 315 | 325 | return $this->TempFileName; |
@@ -73,12 +73,12 @@ discard block |
||
| 73 | 73 | $Extension = strtolower($FileParts['extension']); |
| 74 | 74 | $ValidExtensions = $this->ValidExtensions; |
| 75 | 75 | |
| 76 | - if (!$FileName) { |
|
| 76 | + if ( ! $FileName) { |
|
| 77 | 77 | $this->SetMessage("ERROR: File name is empty."); |
| 78 | 78 | return false; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if (!$ValidExtensions) { |
|
| 81 | + if ( ! $ValidExtensions) { |
|
| 82 | 82 | $this->SetMessage("WARNING: All extensions are valid."); |
| 83 | 83 | return true; |
| 84 | 84 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | $TempFileName = $this->GetTempName(); |
| 105 | 105 | $TempFileSize = filesize($TempFileName); |
| 106 | 106 | |
| 107 | - if($MaximumFileSize == "") { |
|
| 107 | + if ($MaximumFileSize == "") { |
|
| 108 | 108 | $this->SetMessage("WARNING: There is no size restriction."); |
| 109 | 109 | return true; |
| 110 | 110 | } |
@@ -127,11 +127,11 @@ discard block |
||
| 127 | 127 | { |
| 128 | 128 | $FileName = $this->FileName; |
| 129 | 129 | $UploadDirectory = $this->UploadDirectory; |
| 130 | - $File = $UploadDirectory . $FileName; |
|
| 130 | + $File = $UploadDirectory.$FileName; |
|
| 131 | 131 | |
| 132 | 132 | if (file_exists($File)) { |
| 133 | 133 | $this->SetMessage("Message: The file '$FileName' already exist."); |
| 134 | - $UniqueName = rand() . $FileName; |
|
| 134 | + $UniqueName = rand().$FileName; |
|
| 135 | 135 | $this->SetFileName($UniqueName); |
| 136 | 136 | $this->ValidateExistance(); |
| 137 | 137 | } else { |
@@ -149,24 +149,24 @@ discard block |
||
| 149 | 149 | { |
| 150 | 150 | $UploadDirectory = $this->UploadDirectory; |
| 151 | 151 | |
| 152 | - if (!$UploadDirectory) { |
|
| 152 | + if ( ! $UploadDirectory) { |
|
| 153 | 153 | $this->SetMessage("ERROR: The directory variable is empty."); |
| 154 | 154 | return false; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - if (!is_dir($UploadDirectory)) { |
|
| 157 | + if ( ! is_dir($UploadDirectory)) { |
|
| 158 | 158 | $this->SetMessage("ERROR: The directory '$UploadDirectory' does not exist."); |
| 159 | 159 | return false; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - if (!is_writable($UploadDirectory)) { |
|
| 162 | + if ( ! is_writable($UploadDirectory)) { |
|
| 163 | 163 | $this->SetMessage("ERROR: The directory '$UploadDirectory' does not writable."); |
| 164 | 164 | return false; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | if (substr($UploadDirectory, -1) != "/") { |
| 168 | 168 | $this->SetMessage("ERROR: The traling slash does not exist."); |
| 169 | - $NewDirectory = $UploadDirectory . "/"; |
|
| 169 | + $NewDirectory = $UploadDirectory."/"; |
|
| 170 | 170 | $this->SetUploadDirectory($NewDirectory); |
| 171 | 171 | $this->ValidateDirectory(); |
| 172 | 172 | } else { |
@@ -185,9 +185,9 @@ discard block |
||
| 185 | 185 | $MaximumHeight = $this->MaximumHeight; |
| 186 | 186 | $TempFileName = $this->TempFileName; |
| 187 | 187 | |
| 188 | - if($Size = @getimagesize($TempFileName)) { |
|
| 189 | - $Width = $Size[0]; //$Width is the width in pixels of the image uploaded to the server. |
|
| 190 | - $Height = $Size[1]; //$Height is the height in pixels of the image uploaded to the server. |
|
| 188 | + if ($Size = @getimagesize($TempFileName)) { |
|
| 189 | + $Width = $Size[0]; //$Width is the width in pixels of the image uploaded to the server. |
|
| 190 | + $Height = $Size[1]; //$Height is the height in pixels of the image uploaded to the server. |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | if ($Width > $MaximumWidth) { |
@@ -212,11 +212,11 @@ discard block |
||
| 212 | 212 | public function uploadFile() |
| 213 | 213 | { |
| 214 | 214 | |
| 215 | - if (!$this->ValidateExtension()) { |
|
| 215 | + if ( ! $this->ValidateExtension()) { |
|
| 216 | 216 | die($this->GetMessage()); |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - else if (!$this->ValidateSize()) { |
|
| 219 | + else if ( ! $this->ValidateSize()) { |
|
| 220 | 220 | die($this->GetMessage()); |
| 221 | 221 | } |
| 222 | 222 | |
@@ -224,11 +224,11 @@ discard block |
||
| 224 | 224 | die($this->GetMessage()); |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - else if (!$this->ValidateDirectory()) { |
|
| 227 | + else if ( ! $this->ValidateDirectory()) { |
|
| 228 | 228 | die($this->GetMessage()); |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - else if ($this->IsImage && !$this->ValidateImage()) { |
|
| 231 | + else if ($this->IsImage && ! $this->ValidateImage()) { |
|
| 232 | 232 | die($this->GetMessage()); |
| 233 | 233 | } |
| 234 | 234 | |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | $UploadDirectory = $this->UploadDirectory; |
| 240 | 240 | |
| 241 | 241 | if (is_uploaded_file($TempFileName)) { |
| 242 | - move_uploaded_file($TempFileName, $UploadDirectory . $FileName); |
|
| 242 | + move_uploaded_file($TempFileName, $UploadDirectory.$FileName); |
|
| 243 | 243 | return true; |
| 244 | 244 | } else { |
| 245 | 245 | return false; |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | |
| 323 | 323 | public function GetMessage() |
| 324 | 324 | { |
| 325 | - if (!isset($this->Message)) { |
|
| 325 | + if ( ! isset($this->Message)) { |
|
| 326 | 326 | $this->SetMessage("No Message"); |
| 327 | 327 | } |
| 328 | 328 | |