@@ -14,7 +14,6 @@ |
||
| 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 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | /** |
| 100 | 100 | * This method find a record by id |
| 101 | 101 | * @params int id |
| 102 | - * @return Object |
|
| 102 | + * @return BaseClass |
|
| 103 | 103 | * @throws NoArgumentPassedToFunctionException |
| 104 | 104 | */ |
| 105 | 105 | public static function find($id) |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | /** |
| 143 | 143 | * This method return the current class name |
| 144 | 144 | * $params void |
| 145 | - * @return classname |
|
| 145 | + * @return string|false |
|
| 146 | 146 | */ |
| 147 | 147 | public static function getClassName() |
| 148 | 148 | { |
@@ -20,124 +20,124 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | class BaseClass implements InterfaceBaseClass |
| 22 | 22 | { |
| 23 | - protected $databaseModel; // Private variable that contains instance of database |
|
| 24 | - protected $tableName; // Class variable holding class name pluralized |
|
| 25 | - protected $properties = []; // Properties will later contain key, value pairs from the magic setter, getter methods |
|
| 26 | - use Inflector; // Inject the inflector trait |
|
| 23 | + protected $databaseModel; // Private variable that contains instance of database |
|
| 24 | + protected $tableName; // Class variable holding class name pluralized |
|
| 25 | + protected $properties = []; // Properties will later contain key, value pairs from the magic setter, getter methods |
|
| 26 | + use Inflector; // Inject the inflector trait |
|
| 27 | 27 | |
| 28 | - public function __construct() |
|
| 29 | - { |
|
| 30 | - $this->tableName = $this->getClassName(); |
|
| 28 | + public function __construct() |
|
| 29 | + { |
|
| 30 | + $this->tableName = $this->getClassName(); |
|
| 31 | 31 | $this->databaseModel = new DatabaseHandler($this->tableName); |
| 32 | 32 | $this->properties['id'] = 0; |
| 33 | - } |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * The magic getter method |
|
| 37 | - * @params key |
|
| 38 | - * @return array key |
|
| 39 | - */ |
|
| 40 | - public function __get($key) |
|
| 41 | - { |
|
| 42 | - $this->properties[$key]; |
|
| 43 | - } |
|
| 35 | + /** |
|
| 36 | + * The magic getter method |
|
| 37 | + * @params key |
|
| 38 | + * @return array key |
|
| 39 | + */ |
|
| 40 | + public function __get($key) |
|
| 41 | + { |
|
| 42 | + $this->properties[$key]; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * The magic setter method |
|
| 47 | - * @params property, key |
|
| 48 | - * @return array associative array properties |
|
| 49 | - */ |
|
| 50 | - public function __set($property, $value) |
|
| 51 | - { |
|
| 52 | - $this->properties[$property] = $value; |
|
| 53 | - } |
|
| 45 | + /** |
|
| 46 | + * The magic setter method |
|
| 47 | + * @params property, key |
|
| 48 | + * @return array associative array properties |
|
| 49 | + */ |
|
| 50 | + public function __set($property, $value) |
|
| 51 | + { |
|
| 52 | + $this->properties[$property] = $value; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * This method gets all the record from a particular table |
|
| 57 | - * @params void |
|
| 58 | - * @return associative array |
|
| 59 | - * @throws NoRecordFoundException |
|
| 60 | - */ |
|
| 61 | - public static function getAll() |
|
| 62 | - { |
|
| 63 | - $allData = DatabaseHandler::read($id = false, self::getClassName()); |
|
| 64 | - if (count($allData) > 0) { |
|
| 65 | - return $allData; |
|
| 66 | - } |
|
| 67 | - throw NoRecordFoundException::checkNoRecordFoundException("There is no record to display"); |
|
| 68 | - } |
|
| 55 | + /** |
|
| 56 | + * This method gets all the record from a particular table |
|
| 57 | + * @params void |
|
| 58 | + * @return associative array |
|
| 59 | + * @throws NoRecordFoundException |
|
| 60 | + */ |
|
| 61 | + public static function getAll() |
|
| 62 | + { |
|
| 63 | + $allData = DatabaseHandler::read($id = false, self::getClassName()); |
|
| 64 | + if (count($allData) > 0) { |
|
| 65 | + return $allData; |
|
| 66 | + } |
|
| 67 | + throw NoRecordFoundException::checkNoRecordFoundException("There is no record to display"); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * This method create or update record in a database table |
|
| 72 | - * @params void |
|
| 73 | - * @return bool true or false; |
|
| 74 | - * @throws EmptyArrayException |
|
| 75 | - * @throws NoRecordInsertionException |
|
| 76 | - * @throws NoRecordUpdateException |
|
| 77 | - */ |
|
| 78 | - public function save() |
|
| 79 | - { |
|
| 80 | - $boolCommit = false; |
|
| 81 | - if ($this->properties['id']) { |
|
| 82 | - $allData = DatabaseHandler::read($id = $this->properties['id'], self::getClassName()); |
|
| 83 | - if ($this->checkIfRecordIsEmpty($allData)) { |
|
| 84 | - $boolCommit = $this->databaseModel->update(['id' => $this->properties['id']], $this->tableName, $this->properties); |
|
| 85 | - if ($boolCommit) { |
|
| 86 | - return true; |
|
| 87 | - } |
|
| 88 | - throw NoRecordUpdateException::checkNoRecordUpdateException("Record not updated successfully"); |
|
| 89 | - } |
|
| 90 | - throw EmptyArrayException::checkEmptyArrayException("Value passed didn't match any record"); |
|
| 91 | - } |
|
| 92 | - $boolCommit = $this->databaseModel->create($this->properties, $this->tableName); |
|
| 93 | - if ($boolCommit) { |
|
| 94 | - return true; |
|
| 95 | - } |
|
| 96 | - throw NoRecordInsertionException::checkNoRecordAddedException("Record not created successfully"); |
|
| 97 | - } |
|
| 70 | + /** |
|
| 71 | + * This method create or update record in a database table |
|
| 72 | + * @params void |
|
| 73 | + * @return bool true or false; |
|
| 74 | + * @throws EmptyArrayException |
|
| 75 | + * @throws NoRecordInsertionException |
|
| 76 | + * @throws NoRecordUpdateException |
|
| 77 | + */ |
|
| 78 | + public function save() |
|
| 79 | + { |
|
| 80 | + $boolCommit = false; |
|
| 81 | + if ($this->properties['id']) { |
|
| 82 | + $allData = DatabaseHandler::read($id = $this->properties['id'], self::getClassName()); |
|
| 83 | + if ($this->checkIfRecordIsEmpty($allData)) { |
|
| 84 | + $boolCommit = $this->databaseModel->update(['id' => $this->properties['id']], $this->tableName, $this->properties); |
|
| 85 | + if ($boolCommit) { |
|
| 86 | + return true; |
|
| 87 | + } |
|
| 88 | + throw NoRecordUpdateException::checkNoRecordUpdateException("Record not updated successfully"); |
|
| 89 | + } |
|
| 90 | + throw EmptyArrayException::checkEmptyArrayException("Value passed didn't match any record"); |
|
| 91 | + } |
|
| 92 | + $boolCommit = $this->databaseModel->create($this->properties, $this->tableName); |
|
| 93 | + if ($boolCommit) { |
|
| 94 | + return true; |
|
| 95 | + } |
|
| 96 | + throw NoRecordInsertionException::checkNoRecordAddedException("Record not created successfully"); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * This method find a record by id |
|
| 101 | - * @params int id |
|
| 102 | - * @return Object |
|
| 103 | - * @throws NoArgumentPassedToFunctionException |
|
| 104 | - */ |
|
| 105 | - public static function find($id) |
|
| 106 | - { |
|
| 107 | - $num_args = (int) func_num_args(); // get number of arguments passed to |
|
| 108 | - if ($num_args == 0 || $num_args > 1) { |
|
| 109 | - throw NoArgumentPassedToFunctionException::checkNoArgumentPassedToFunction("Argument missing: only one argument is allowed"); |
|
| 110 | - } |
|
| 111 | - if ($id == "") { |
|
| 112 | - throw NullArgumentPassedToFunction::ckeckNullArgumentPassedToFunction("This function expect a value"); |
|
| 113 | - } |
|
| 114 | - $staticFindInstance = new static(); |
|
| 115 | - $staticFindInstance->id = $id == "" ? false : $id; |
|
| 116 | - return $staticFindInstance; |
|
| 99 | + /** |
|
| 100 | + * This method find a record by id |
|
| 101 | + * @params int id |
|
| 102 | + * @return Object |
|
| 103 | + * @throws NoArgumentPassedToFunctionException |
|
| 104 | + */ |
|
| 105 | + public static function find($id) |
|
| 106 | + { |
|
| 107 | + $num_args = (int) func_num_args(); // get number of arguments passed to |
|
| 108 | + if ($num_args == 0 || $num_args > 1) { |
|
| 109 | + throw NoArgumentPassedToFunctionException::checkNoArgumentPassedToFunction("Argument missing: only one argument is allowed"); |
|
| 110 | + } |
|
| 111 | + if ($id == "") { |
|
| 112 | + throw NullArgumentPassedToFunction::ckeckNullArgumentPassedToFunction("This function expect a value"); |
|
| 113 | + } |
|
| 114 | + $staticFindInstance = new static(); |
|
| 115 | + $staticFindInstance->id = $id == "" ? false : $id; |
|
| 116 | + return $staticFindInstance; |
|
| 117 | 117 | |
| 118 | - } |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - /** |
|
| 121 | - * This method delete a row from the table by the row id |
|
| 122 | - * @params int id |
|
| 123 | - * @return boolean true or false |
|
| 124 | - * @throws NoRecordDeletionException; |
|
| 125 | - */ |
|
| 126 | - public static function destroy($id) |
|
| 127 | - { |
|
| 128 | - $boolDeleted = false; |
|
| 129 | - $num_args = (int) func_num_args(); // get number of arguments passed to |
|
| 120 | + /** |
|
| 121 | + * This method delete a row from the table by the row id |
|
| 122 | + * @params int id |
|
| 123 | + * @return boolean true or false |
|
| 124 | + * @throws NoRecordDeletionException; |
|
| 125 | + */ |
|
| 126 | + public static function destroy($id) |
|
| 127 | + { |
|
| 128 | + $boolDeleted = false; |
|
| 129 | + $num_args = (int) func_num_args(); // get number of arguments passed to |
|
| 130 | 130 | |
| 131 | - if ($num_args == 0 || $num_args > 1) { |
|
| 132 | - throw NoArgumentPassedToFunctionException::checkNoArgumentPassedToFunction("Argument missing: only one argument is allowed"); |
|
| 133 | - } |
|
| 134 | - $boolDeleted = DatabaseHandler::delete($id, self::getClassName()); |
|
| 135 | - if ($boolDeleted) { |
|
| 136 | - return true; |
|
| 137 | - } |
|
| 138 | - throw NoRecordDeletionException::checkNoRecordUpdateException("Record deletion unsuccessful because id does not match any record"); |
|
| 131 | + if ($num_args == 0 || $num_args > 1) { |
|
| 132 | + throw NoArgumentPassedToFunctionException::checkNoArgumentPassedToFunction("Argument missing: only one argument is allowed"); |
|
| 133 | + } |
|
| 134 | + $boolDeleted = DatabaseHandler::delete($id, self::getClassName()); |
|
| 135 | + if ($boolDeleted) { |
|
| 136 | + return true; |
|
| 137 | + } |
|
| 138 | + throw NoRecordDeletionException::checkNoRecordUpdateException("Record deletion unsuccessful because id does not match any record"); |
|
| 139 | 139 | |
| 140 | - } |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | 142 | /** |
| 143 | 143 | * This method return the current class name |
@@ -156,12 +156,12 @@ discard block |
||
| 156 | 156 | * @param $arrayOfRecord |
| 157 | 157 | * @return bool |
| 158 | 158 | */ |
| 159 | - public function checkIfRecordIsEmpty($arrayOfRecord) |
|
| 160 | - { |
|
| 161 | - if (count($arrayOfRecord) > 0) { |
|
| 162 | - return true; |
|
| 163 | - } |
|
| 164 | - return false; |
|
| 165 | - } |
|
| 159 | + public function checkIfRecordIsEmpty($arrayOfRecord) |
|
| 160 | + { |
|
| 161 | + if (count($arrayOfRecord) > 0) { |
|
| 162 | + return true; |
|
| 163 | + } |
|
| 164 | + return false; |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | 167 | } |
@@ -74,14 +74,14 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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) { |
@@ -6,7 +6,7 @@ |
||
| 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 | |
@@ -12,8 +12,8 @@ |
||
| 12 | 12 | |
| 13 | 13 | class NoRecordInsertionException extends Exception { |
| 14 | 14 | |
| 15 | - public static function checkNoRecordAddedException($mesaage) |
|
| 16 | - { |
|
| 17 | - return new static($mesaage); |
|
| 18 | - } |
|
| 15 | + public static function checkNoRecordAddedException($mesaage) |
|
| 16 | + { |
|
| 17 | + return new static($mesaage); |
|
| 18 | + } |
|
| 19 | 19 | } |
@@ -9,7 +9,6 @@ |
||
| 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 | |
@@ -41,9 +41,9 @@ discard block |
||
| 41 | 41 | { |
| 42 | 42 | $tableFields = $this->getColumnNames($this->model, $this->dbConnection); |
| 43 | 43 | |
| 44 | - $unexpectedFields = self::checkIfMagicSetterContainsIsSameAsClassModel($tableFields,$associative1DArray); |
|
| 44 | + $unexpectedFields = self::checkIfMagicSetterContainsIsSameAsClassModel($tableFields, $associative1DArray); |
|
| 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 | unset($tableFields[0]); |
| 49 | 49 | if (is_null($dbConn)) { |
@@ -55,15 +55,15 @@ discard block |
||
| 55 | 55 | private function insertRecord($dbConn, $tableName, $associative1DArray) |
| 56 | 56 | { |
| 57 | 57 | $insertQuery = 'INSERT INTO '.$tableName; |
| 58 | - $TableValues = implode(',',array_keys($associative1DArray)); |
|
| 58 | + $TableValues = implode(',', array_keys($associative1DArray)); |
|
| 59 | 59 | foreach ($associative1DArray as $field => $value) { |
| 60 | 60 | $FormValues[] = "'".trim(addslashes($value))."'"; |
| 61 | 61 | } |
| 62 | 62 | $splittedTableValues = implode(',', $FormValues); |
| 63 | - $insertQuery.= ' ('.$TableValues.')'; |
|
| 64 | - $insertQuery.= ' VALUES ('.$splittedTableValues.')'; |
|
| 63 | + $insertQuery .= ' ('.$TableValues.')'; |
|
| 64 | + $insertQuery .= ' VALUES ('.$splittedTableValues.')'; |
|
| 65 | 65 | $executeQuery = $dbConn->exec($insertQuery); |
| 66 | - return $executeQuery ? : false; |
|
| 66 | + return $executeQuery ?: false; |
|
| 67 | 67 | |
| 68 | 68 | } |
| 69 | 69 | |
@@ -80,12 +80,12 @@ discard block |
||
| 80 | 80 | } |
| 81 | 81 | $updateSql = "UPDATE `$tableName` SET "; |
| 82 | 82 | unset($associative1DArray['id']); |
| 83 | - $unexpectedFields = self::checkIfMagicSetterContainsIsSameAsClassModel($this->getColumnNames($this->model, $this->dbConnection),$associative1DArray); |
|
| 83 | + $unexpectedFields = self::checkIfMagicSetterContainsIsSameAsClassModel($this->getColumnNames($this->model, $this->dbConnection), $associative1DArray); |
|
| 84 | 84 | |
| 85 | 85 | if (count($unexpectedFields) > 0) { |
| 86 | 86 | throw TableFieldUndefinedException::fieldsNotDefinedException($unexpectedFields, "needs to be created as table field"); |
| 87 | 87 | } |
| 88 | - foreach($associative1DArray as $field => $value) { |
|
| 88 | + foreach ($associative1DArray as $field => $value) { |
|
| 89 | 89 | $sql .= "`$field` = '$value'".","; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | $stmt = $dbConn->prepare($updateSql); |
| 98 | 98 | $boolResponse = $stmt->execute(); |
| 99 | - return $boolResponse ? : false; |
|
| 99 | + return $boolResponse ?: false; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | if (is_null($dbConn)) { |
| 112 | 112 | $dbConn = new DatabaseConnection(); |
| 113 | 113 | } |
| 114 | - $sql = $id ? 'SELECT * FROM '.$tableName.' WHERE id = '.$id : 'SELECT * FROM '.$tableName; |
|
| 114 | + $sql = $id ? 'SELECT * FROM '.$tableName.' WHERE id = '.$id : 'SELECT * FROM '.$tableName; |
|
| 115 | 115 | |
| 116 | 116 | try { |
| 117 | 117 | $stmt = $dbConn->prepare($sql); |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | $results = $stmt->fetchAll(PDO::FETCH_ASSOC); |
| 125 | 125 | |
| 126 | - foreach($results as $result) { |
|
| 126 | + foreach ($results as $result) { |
|
| 127 | 127 | array_push($tableData, $result); |
| 128 | 128 | } |
| 129 | 129 | return $tableData; |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | $sql = 'DELETE FROM '.$tableName.' WHERE id = '.$id; |
| 144 | 144 | $boolResponse = $dbConn->exec($sql); |
| 145 | - return $boolResponse ? : false; |
|
| 145 | + return $boolResponse ?: false; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | { |
| 156 | 156 | $unexpectedFields = []; |
| 157 | 157 | foreach ($userSetterArray as $key => $val) { |
| 158 | - if (!in_array($key,$tableColumn)) { |
|
| 158 | + if (!in_array($key, $tableColumn)) { |
|
| 159 | 159 | $unexpectedFields[] = $key; |
| 160 | 160 | } |
| 161 | 161 | } |
@@ -169,9 +169,9 @@ discard block |
||
| 169 | 169 | */ |
| 170 | 170 | public function prepareUpdateQuery($sql) |
| 171 | 171 | { |
| 172 | - $splittedQuery = explode(",",$sql); |
|
| 172 | + $splittedQuery = explode(",", $sql); |
|
| 173 | 173 | array_pop($splittedQuery); |
| 174 | - $mergeData = implode(",",$splittedQuery); |
|
| 174 | + $mergeData = implode(",", $splittedQuery); |
|
| 175 | 175 | return $mergeData; |
| 176 | 176 | } |
| 177 | 177 | |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | $statement->execute(); |
| 198 | 198 | $returnedRowNumbers = $statement->rowCount(); |
| 199 | 199 | |
| 200 | - return $returnedRowNumbers ? true : false; |
|
| 200 | + return $returnedRowNumbers ? true : false; |
|
| 201 | 201 | } |
| 202 | 202 | throw EmptyArrayException::checkEmptyArrayException("Array Expected: parameter passed to this function is not an array"); |
| 203 | 203 | } |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | $stmt->execute(); |
| 222 | 222 | $results = $stmt->fetchAll(PDO::FETCH_ASSOC); |
| 223 | 223 | |
| 224 | - foreach($results as $result) { |
|
| 224 | + foreach ($results as $result) { |
|
| 225 | 225 | array_push($tableFields, $result['Field']); |
| 226 | 226 | } |
| 227 | 227 | return $tableFields; |
@@ -21,6 +21,7 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * This is a constructor; a default method that will be called automatically during class instantiation |
| 24 | + * @param string|false $modelClassName |
|
| 24 | 25 | */ |
| 25 | 26 | public function __construct($modelClassName, $dbConn = Null) |
| 26 | 27 | { |
@@ -35,7 +36,8 @@ discard block |
||
| 35 | 36 | /** |
| 36 | 37 | * This method create a record and store it in a table row |
| 37 | 38 | * @params associative array, string tablename |
| 38 | - * @return boolean true or false |
|
| 39 | + * @param string|false $tableName |
|
| 40 | + * @return boolean|null true or false |
|
| 39 | 41 | */ |
| 40 | 42 | public function create($associative1DArray, $tableName, $dbConn = Null) |
| 41 | 43 | { |
@@ -70,6 +72,7 @@ discard block |
||
| 70 | 72 | /** |
| 71 | 73 | * This method updates any table by supplying 3 parameter |
| 72 | 74 | * @params: $updateParams, $tableName, $associative1DArray |
| 75 | + * @param string|false $tableName |
|
| 73 | 76 | * @return boolean true or false |
| 74 | 77 | */ |
| 75 | 78 | public function update(array $updateParams, $tableName, $associative1DArray, $dbConn = Null) |
@@ -102,6 +105,7 @@ discard block |
||
| 102 | 105 | /** |
| 103 | 106 | * This method retrieves record from a table |
| 104 | 107 | * @params int id, string tableName |
| 108 | + * @param string|false $tableName |
|
| 105 | 109 | * @return array |
| 106 | 110 | */ |
| 107 | 111 | public static function read($id, $tableName, $dbConn = Null) |
@@ -132,6 +136,7 @@ discard block |
||
| 132 | 136 | /** |
| 133 | 137 | * This method deletes a record from a table row |
| 134 | 138 | * @params int id, string tableName |
| 139 | + * @param string|false $tableName |
|
| 135 | 140 | * @return boolean true or false |
| 136 | 141 | */ |
| 137 | 142 | public static function delete($id, $tableName, $dbConn = Null) |
@@ -164,7 +169,7 @@ discard block |
||
| 164 | 169 | |
| 165 | 170 | /** |
| 166 | 171 | * This method returns sql query |
| 167 | - * @param $sql |
|
| 172 | + * @param string $sql |
|
| 168 | 173 | * @return string |
| 169 | 174 | */ |
| 170 | 175 | public function prepareUpdateQuery($sql) |
@@ -206,6 +211,7 @@ discard block |
||
| 206 | 211 | * This method returns column fields of a particular table |
| 207 | 212 | * @param $table |
| 208 | 213 | * @param $conn |
| 214 | + * @param DatabaseConnection $dbConn |
|
| 209 | 215 | * @return array |
| 210 | 216 | */ |
| 211 | 217 | public function getColumnNames($table, $dbConn = Null) { |
@@ -14,90 +14,90 @@ discard block |
||
| 14 | 14 | use Laztopaz\potatoORM\EmptyArrayException; |
| 15 | 15 | |
| 16 | 16 | class DatabaseHandler { |
| 17 | - private $tableFields; |
|
| 18 | - private $dbHelperInstance; |
|
| 19 | - private $dbConnection; |
|
| 20 | - private $model; |
|
| 17 | + private $tableFields; |
|
| 18 | + private $dbHelperInstance; |
|
| 19 | + private $dbConnection; |
|
| 20 | + private $model; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * This is a constructor; a default method that will be called automatically during class instantiation |
|
| 24 | - */ |
|
| 25 | - public function __construct($modelClassName, $dbConn = Null) |
|
| 26 | - { |
|
| 27 | - if (is_null($dbConn)) { |
|
| 28 | - $this->dbConnection = new DatabaseConnection(); |
|
| 29 | - } else { |
|
| 30 | - $this->dbConnection = $dbConn; |
|
| 31 | - } |
|
| 32 | - $this->model = $modelClassName; |
|
| 33 | - } |
|
| 22 | + /** |
|
| 23 | + * This is a constructor; a default method that will be called automatically during class instantiation |
|
| 24 | + */ |
|
| 25 | + public function __construct($modelClassName, $dbConn = Null) |
|
| 26 | + { |
|
| 27 | + if (is_null($dbConn)) { |
|
| 28 | + $this->dbConnection = new DatabaseConnection(); |
|
| 29 | + } else { |
|
| 30 | + $this->dbConnection = $dbConn; |
|
| 31 | + } |
|
| 32 | + $this->model = $modelClassName; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * This method create a record and store it in a table row |
|
| 37 | - * @params associative array, string tablename |
|
| 38 | - * @return boolean true or false |
|
| 39 | - */ |
|
| 40 | - public function create($associative1DArray, $tableName, $dbConn = Null) |
|
| 41 | - { |
|
| 42 | - $tableFields = $this->getColumnNames($this->model, $this->dbConnection); |
|
| 35 | + /** |
|
| 36 | + * This method create a record and store it in a table row |
|
| 37 | + * @params associative array, string tablename |
|
| 38 | + * @return boolean true or false |
|
| 39 | + */ |
|
| 40 | + public function create($associative1DArray, $tableName, $dbConn = Null) |
|
| 41 | + { |
|
| 42 | + $tableFields = $this->getColumnNames($this->model, $this->dbConnection); |
|
| 43 | 43 | |
| 44 | - $unexpectedFields = self::checkIfMagicSetterContainsIsSameAsClassModel($tableFields,$associative1DArray); |
|
| 45 | - if (count($unexpectedFields) > 0) { |
|
| 46 | - throw TableFieldUndefinedException::fieldsNotDefinedException($unexpectedFields,"needs to be created as table field"); |
|
| 47 | - } |
|
| 48 | - unset($tableFields[0]); |
|
| 49 | - if (is_null($dbConn)) { |
|
| 50 | - $dbConn = $this->dbConnection; |
|
| 51 | - } |
|
| 52 | - $this->insertRecord($dbConn, $tableName, $associative1DArray); |
|
| 53 | - } |
|
| 44 | + $unexpectedFields = self::checkIfMagicSetterContainsIsSameAsClassModel($tableFields,$associative1DArray); |
|
| 45 | + if (count($unexpectedFields) > 0) { |
|
| 46 | + throw TableFieldUndefinedException::fieldsNotDefinedException($unexpectedFields,"needs to be created as table field"); |
|
| 47 | + } |
|
| 48 | + unset($tableFields[0]); |
|
| 49 | + if (is_null($dbConn)) { |
|
| 50 | + $dbConn = $this->dbConnection; |
|
| 51 | + } |
|
| 52 | + $this->insertRecord($dbConn, $tableName, $associative1DArray); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - private function insertRecord($dbConn, $tableName, $associative1DArray) |
|
| 56 | - { |
|
| 57 | - $insertQuery = 'INSERT INTO '.$tableName; |
|
| 58 | - $TableValues = implode(',',array_keys($associative1DArray)); |
|
| 59 | - foreach ($associative1DArray as $field => $value) { |
|
| 60 | - $FormValues[] = "'".trim(addslashes($value))."'"; |
|
| 61 | - } |
|
| 62 | - $splittedTableValues = implode(',', $FormValues); |
|
| 63 | - $insertQuery.= ' ('.$TableValues.')'; |
|
| 64 | - $insertQuery.= ' VALUES ('.$splittedTableValues.')'; |
|
| 65 | - $executeQuery = $dbConn->exec($insertQuery); |
|
| 66 | - return $executeQuery ? : false; |
|
| 55 | + private function insertRecord($dbConn, $tableName, $associative1DArray) |
|
| 56 | + { |
|
| 57 | + $insertQuery = 'INSERT INTO '.$tableName; |
|
| 58 | + $TableValues = implode(',',array_keys($associative1DArray)); |
|
| 59 | + foreach ($associative1DArray as $field => $value) { |
|
| 60 | + $FormValues[] = "'".trim(addslashes($value))."'"; |
|
| 61 | + } |
|
| 62 | + $splittedTableValues = implode(',', $FormValues); |
|
| 63 | + $insertQuery.= ' ('.$TableValues.')'; |
|
| 64 | + $insertQuery.= ' VALUES ('.$splittedTableValues.')'; |
|
| 65 | + $executeQuery = $dbConn->exec($insertQuery); |
|
| 66 | + return $executeQuery ? : false; |
|
| 67 | 67 | |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * This method updates any table by supplying 3 parameter |
|
| 72 | - * @params: $updateParams, $tableName, $associative1DArray |
|
| 73 | - * @return boolean true or false |
|
| 74 | - */ |
|
| 75 | - public function update(array $updateParams, $tableName, $associative1DArray, $dbConn = Null) |
|
| 76 | - { |
|
| 77 | - $sql = ""; |
|
| 78 | - if (is_null($dbConn)) { |
|
| 79 | - $dbConn = $this->dbConnection; |
|
| 80 | - } |
|
| 81 | - $updateSql = "UPDATE `$tableName` SET "; |
|
| 82 | - unset($associative1DArray['id']); |
|
| 83 | - $unexpectedFields = self::checkIfMagicSetterContainsIsSameAsClassModel($this->getColumnNames($this->model, $this->dbConnection),$associative1DArray); |
|
| 70 | + /** |
|
| 71 | + * This method updates any table by supplying 3 parameter |
|
| 72 | + * @params: $updateParams, $tableName, $associative1DArray |
|
| 73 | + * @return boolean true or false |
|
| 74 | + */ |
|
| 75 | + public function update(array $updateParams, $tableName, $associative1DArray, $dbConn = Null) |
|
| 76 | + { |
|
| 77 | + $sql = ""; |
|
| 78 | + if (is_null($dbConn)) { |
|
| 79 | + $dbConn = $this->dbConnection; |
|
| 80 | + } |
|
| 81 | + $updateSql = "UPDATE `$tableName` SET "; |
|
| 82 | + unset($associative1DArray['id']); |
|
| 83 | + $unexpectedFields = self::checkIfMagicSetterContainsIsSameAsClassModel($this->getColumnNames($this->model, $this->dbConnection),$associative1DArray); |
|
| 84 | 84 | |
| 85 | - if (count($unexpectedFields) > 0) { |
|
| 86 | - throw TableFieldUndefinedException::fieldsNotDefinedException($unexpectedFields, "needs to be created as table field"); |
|
| 87 | - } |
|
| 88 | - foreach($associative1DArray as $field => $value) { |
|
| 89 | - $sql .= "`$field` = '$value'".","; |
|
| 90 | - } |
|
| 85 | + if (count($unexpectedFields) > 0) { |
|
| 86 | + throw TableFieldUndefinedException::fieldsNotDefinedException($unexpectedFields, "needs to be created as table field"); |
|
| 87 | + } |
|
| 88 | + foreach($associative1DArray as $field => $value) { |
|
| 89 | + $sql .= "`$field` = '$value'".","; |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - $updateSql .= $this->prepareUpdateQuery($sql); |
|
| 92 | + $updateSql .= $this->prepareUpdateQuery($sql); |
|
| 93 | 93 | |
| 94 | - foreach ($updateParams as $key => $val) { |
|
| 95 | - $updateSql .= " WHERE $key = $val"; |
|
| 96 | - } |
|
| 97 | - $stmt = $dbConn->prepare($updateSql); |
|
| 98 | - $boolResponse = $stmt->execute(); |
|
| 99 | - return $boolResponse ? : false; |
|
| 100 | - } |
|
| 94 | + foreach ($updateParams as $key => $val) { |
|
| 95 | + $updateSql .= " WHERE $key = $val"; |
|
| 96 | + } |
|
| 97 | + $stmt = $dbConn->prepare($updateSql); |
|
| 98 | + $boolResponse = $stmt->execute(); |
|
| 99 | + return $boolResponse ? : false; |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | 102 | /** |
| 103 | 103 | * This method retrieves record from a table |
@@ -109,22 +109,22 @@ discard block |
||
| 109 | 109 | $tableData = []; |
| 110 | 110 | |
| 111 | 111 | if (is_null($dbConn)) { |
| 112 | - $dbConn = new DatabaseConnection(); |
|
| 112 | + $dbConn = new DatabaseConnection(); |
|
| 113 | 113 | } |
| 114 | 114 | $sql = $id ? 'SELECT * FROM '.$tableName.' WHERE id = '.$id : 'SELECT * FROM '.$tableName; |
| 115 | 115 | |
| 116 | 116 | try { |
| 117 | - $stmt = $dbConn->prepare($sql); |
|
| 118 | - $stmt->bindValue(':table', $tableName); |
|
| 119 | - $stmt->bindValue(':id', $id); |
|
| 120 | - $stmt->execute(); |
|
| 117 | + $stmt = $dbConn->prepare($sql); |
|
| 118 | + $stmt->bindValue(':table', $tableName); |
|
| 119 | + $stmt->bindValue(':id', $id); |
|
| 120 | + $stmt->execute(); |
|
| 121 | 121 | } catch (PDOException $e) { |
| 122 | - return $e->getMessage(); |
|
| 122 | + return $e->getMessage(); |
|
| 123 | 123 | } |
| 124 | 124 | $results = $stmt->fetchAll(PDO::FETCH_ASSOC); |
| 125 | 125 | |
| 126 | 126 | foreach($results as $result) { |
| 127 | - array_push($tableData, $result); |
|
| 127 | + array_push($tableData, $result); |
|
| 128 | 128 | } |
| 129 | 129 | return $tableData; |
| 130 | 130 | } |
@@ -136,13 +136,13 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | public static function delete($id, $tableName, $dbConn = Null) |
| 138 | 138 | { |
| 139 | - if (is_null($dbConn)) { |
|
| 140 | - $dbConn = new DatabaseConnection(); |
|
| 141 | - } |
|
| 139 | + if (is_null($dbConn)) { |
|
| 140 | + $dbConn = new DatabaseConnection(); |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - $sql = 'DELETE FROM '.$tableName.' WHERE id = '.$id; |
|
| 144 | - $boolResponse = $dbConn->exec($sql); |
|
| 145 | - return $boolResponse ? : false; |
|
| 143 | + $sql = 'DELETE FROM '.$tableName.' WHERE id = '.$id; |
|
| 144 | + $boolResponse = $dbConn->exec($sql); |
|
| 145 | + return $boolResponse ? : false; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -153,13 +153,13 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | public static function checkIfMagicSetterContainsIsSameAsClassModel(array $tableColumn, array $userSetterArray) |
| 155 | 155 | { |
| 156 | - $unexpectedFields = []; |
|
| 157 | - foreach ($userSetterArray as $key => $val) { |
|
| 158 | - if (!in_array($key,$tableColumn)) { |
|
| 159 | - $unexpectedFields[] = $key; |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - return $unexpectedFields; |
|
| 156 | + $unexpectedFields = []; |
|
| 157 | + foreach ($userSetterArray as $key => $val) { |
|
| 158 | + if (!in_array($key,$tableColumn)) { |
|
| 159 | + $unexpectedFields[] = $key; |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + return $unexpectedFields; |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -169,10 +169,10 @@ discard block |
||
| 169 | 169 | */ |
| 170 | 170 | public function prepareUpdateQuery($sql) |
| 171 | 171 | { |
| 172 | - $splittedQuery = explode(",",$sql); |
|
| 173 | - array_pop($splittedQuery); |
|
| 174 | - $mergeData = implode(",",$splittedQuery); |
|
| 175 | - return $mergeData; |
|
| 172 | + $splittedQuery = explode(",",$sql); |
|
| 173 | + array_pop($splittedQuery); |
|
| 174 | + $mergeData = implode(",",$splittedQuery); |
|
| 175 | + return $mergeData; |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
@@ -184,22 +184,22 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | public function findAndWhere($params, $tableName, $dbConn) |
| 186 | 186 | { |
| 187 | - if (is_null($dbConn)) { |
|
| 188 | - $dbConn = $this->dbConnection; |
|
| 189 | - } |
|
| 190 | - if (is_array($params) && !empty($params)) { |
|
| 191 | - $sql = "SELECT * FROM ".$tableName; |
|
| 187 | + if (is_null($dbConn)) { |
|
| 188 | + $dbConn = $this->dbConnection; |
|
| 189 | + } |
|
| 190 | + if (is_array($params) && !empty($params)) { |
|
| 191 | + $sql = "SELECT * FROM ".$tableName; |
|
| 192 | 192 | |
| 193 | - foreach ($params as $key => $val) { |
|
| 194 | - $sql .= " WHERE `$key` = '$val'"; |
|
| 195 | - } |
|
| 196 | - $statement = $dbConn->prepare($sql); |
|
| 197 | - $statement->execute(); |
|
| 198 | - $returnedRowNumbers = $statement->rowCount(); |
|
| 193 | + foreach ($params as $key => $val) { |
|
| 194 | + $sql .= " WHERE `$key` = '$val'"; |
|
| 195 | + } |
|
| 196 | + $statement = $dbConn->prepare($sql); |
|
| 197 | + $statement->execute(); |
|
| 198 | + $returnedRowNumbers = $statement->rowCount(); |
|
| 199 | 199 | |
| 200 | - return $returnedRowNumbers ? true : false; |
|
| 201 | - } |
|
| 202 | - throw EmptyArrayException::checkEmptyArrayException("Array Expected: parameter passed to this function is not an array"); |
|
| 200 | + return $returnedRowNumbers ? true : false; |
|
| 201 | + } |
|
| 202 | + throw EmptyArrayException::checkEmptyArrayException("Array Expected: parameter passed to this function is not an array"); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
@@ -209,22 +209,22 @@ discard block |
||
| 209 | 209 | * @return array |
| 210 | 210 | */ |
| 211 | 211 | public function getColumnNames($table, $dbConn = Null) { |
| 212 | - $tableFields = []; |
|
| 212 | + $tableFields = []; |
|
| 213 | 213 | |
| 214 | - if (is_null($dbConn)) { |
|
| 215 | - $dbConn = $this->dbConnection; |
|
| 216 | - } |
|
| 217 | - $sql = "SHOW COLUMNS FROM ".$table; |
|
| 214 | + if (is_null($dbConn)) { |
|
| 215 | + $dbConn = $this->dbConnection; |
|
| 216 | + } |
|
| 217 | + $sql = "SHOW COLUMNS FROM ".$table; |
|
| 218 | 218 | |
| 219 | - $stmt = $dbConn->prepare($sql); |
|
| 220 | - $stmt->bindValue(':table', $table, PDO::PARAM_STR); |
|
| 221 | - $stmt->execute(); |
|
| 222 | - $results = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|
| 219 | + $stmt = $dbConn->prepare($sql); |
|
| 220 | + $stmt->bindValue(':table', $table, PDO::PARAM_STR); |
|
| 221 | + $stmt->execute(); |
|
| 222 | + $results = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|
| 223 | 223 | |
| 224 | - foreach($results as $result) { |
|
| 225 | - array_push($tableFields, $result['Field']); |
|
| 226 | - } |
|
| 227 | - return $tableFields; |
|
| 224 | + foreach($results as $result) { |
|
| 225 | + array_push($tableFields, $result['Field']); |
|
| 226 | + } |
|
| 227 | + return $tableFields; |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | } |
@@ -8,7 +8,6 @@ |
||
| 8 | 8 | |
| 9 | 9 | namespace Laztopaz\potatoORM; |
| 10 | 10 | |
| 11 | -use PDO; |
|
| 12 | 11 | use Laztopaz\potatoORM\TableNotCreatedException; |
| 13 | 12 | |
| 14 | 13 | class DatabaseHelper { |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | } |
| 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 | throw TableNotCreatedException::tableNotCreatedException("Check your database connection"); |
@@ -13,25 +13,25 @@ |
||
| 13 | 13 | |
| 14 | 14 | class DatabaseHelper { |
| 15 | 15 | |
| 16 | - public $dbConn; |
|
| 16 | + public $dbConn; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * This is a constructor; a default method that will be called automatically during class instantiation |
|
| 20 | - */ |
|
| 21 | - public function __construct($dbConnect) |
|
| 22 | - { |
|
| 23 | - $this->dbConn = $dbConnect; |
|
| 24 | - } |
|
| 18 | + /** |
|
| 19 | + * This is a constructor; a default method that will be called automatically during class instantiation |
|
| 20 | + */ |
|
| 21 | + public function __construct($dbConnect) |
|
| 22 | + { |
|
| 23 | + $this->dbConn = $dbConnect; |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * This method creates a particular table |
|
| 28 | - * @param tableName |
|
| 29 | - * $return boolean true or false |
|
| 30 | - */ |
|
| 26 | + /** |
|
| 27 | + * This method creates a particular table |
|
| 28 | + * @param tableName |
|
| 29 | + * $return boolean true or false |
|
| 30 | + */ |
|
| 31 | 31 | public function createTable($tableName, $conn = NULL) |
| 32 | 32 | { |
| 33 | 33 | if (is_null($conn)) { |
| 34 | - $conn = $this->dbConn; |
|
| 34 | + $conn = $this->dbConn; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | $sql = 'CREATE TABLE IF NOT EXISTS '.$tableName.'('; |
@@ -12,8 +12,8 @@ |
||
| 12 | 12 | |
| 13 | 13 | class NoRecordDeletionException extends Exception |
| 14 | 14 | { |
| 15 | - public static function checkNoRecordUpdateException($message) |
|
| 16 | - { |
|
| 17 | - return new static($message); |
|
| 18 | - } |
|
| 15 | + public static function checkNoRecordUpdateException($message) |
|
| 16 | + { |
|
| 17 | + return new static($message); |
|
| 18 | + } |
|
| 19 | 19 | } |
@@ -12,9 +12,9 @@ |
||
| 12 | 12 | |
| 13 | 13 | class EmptyArrayException extends Exception { |
| 14 | 14 | |
| 15 | - public static function checkEmptyArrayException($message) |
|
| 16 | - { |
|
| 17 | - return new static($message); |
|
| 18 | - } |
|
| 15 | + public static function checkEmptyArrayException($message) |
|
| 16 | + { |
|
| 17 | + return new static($message); |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | 20 | } |
@@ -12,9 +12,9 @@ |
||
| 12 | 12 | |
| 13 | 13 | class NoArgumentPassedToFunctionException extends Exception { |
| 14 | 14 | |
| 15 | - public static function checkNoArgumentPassedToFunction($message) |
|
| 16 | - { |
|
| 17 | - return new static($message); |
|
| 18 | - } |
|
| 15 | + public static function checkNoArgumentPassedToFunction($message) |
|
| 16 | + { |
|
| 17 | + return new static($message); |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | 20 | } |
@@ -12,9 +12,9 @@ |
||
| 12 | 12 | |
| 13 | 13 | class NoRecordUpdateException extends Exception { |
| 14 | 14 | |
| 15 | - public static function checkNoRecordUpdateException($message) |
|
| 16 | - { |
|
| 17 | - return new static($message); |
|
| 18 | - } |
|
| 15 | + public static function checkNoRecordUpdateException($message) |
|
| 16 | + { |
|
| 17 | + return new static($message); |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | 20 | } |