@@ -371,6 +371,7 @@ discard block |
||
| 371 | 371 | /** |
| 372 | 372 | * Delete model with the specified id. |
| 373 | 373 | * |
| 374 | + * @return boolean |
|
| 374 | 375 | */ |
| 375 | 376 | static function destroy($id); |
| 376 | 377 | } |
@@ -445,7 +446,7 @@ discard block |
||
| 445 | 446 | * Determine if a given string contains a given substring. |
| 446 | 447 | * |
| 447 | 448 | * @param string $haystack |
| 448 | - * @param string|array $needles |
|
| 449 | + * @param string[] $needles |
|
| 449 | 450 | * @return bool |
| 450 | 451 | */ |
| 451 | 452 | public static function contains($haystack, $needles) |
@@ -146,28 +146,28 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | /** |
| 148 | 148 | * Store instance of database connection used. |
| 149 | - * @var [type] |
|
| 150 | - */ |
|
| 149 | + * @var [type] |
|
| 150 | + */ |
|
| 151 | 151 | protected $databaseConnection; |
| 152 | 152 | |
| 153 | - public function __construct() |
|
| 153 | + public function __construct() |
|
| 154 | 154 | { |
| 155 | 155 | $this->databaseConnection = DatabaseConnection::getInstance()->databaseConnection; |
| 156 | 156 | //$databaseConnection->databaseConnection->connect(); |
| 157 | 157 | } |
| 158 | 158 | /** |
| 159 | - * @param string $key rep column name |
|
| 160 | - * @param string $val rep column value |
|
| 161 | - * sets into $propertie the $key => $value pairs |
|
| 162 | - */ |
|
| 159 | + * @param string $key rep column name |
|
| 160 | + * @param string $val rep column value |
|
| 161 | + * sets into $propertie the $key => $value pairs |
|
| 162 | + */ |
|
| 163 | 163 | public function __set($key, $val) |
| 164 | 164 | { |
| 165 | 165 | $this->properties[$key] = $val; |
| 166 | 166 | } |
| 167 | 167 | /** |
| 168 | - * @param string $key reps the column name |
|
| 169 | - * @return $key and $value |
|
| 170 | - */ |
|
| 168 | + * @param string $key reps the column name |
|
| 169 | + * @return $key and $value |
|
| 170 | + */ |
|
| 171 | 171 | public function __get($key) |
| 172 | 172 | { |
| 173 | 173 | return $this->properties[$key]; |
@@ -177,17 +177,17 @@ discard block |
||
| 177 | 177 | * |
| 178 | 178 | * @return array |
| 179 | 179 | */ |
| 180 | - public function getProperties() |
|
| 181 | - { |
|
| 182 | - return $this->properties; |
|
| 183 | - } |
|
| 180 | + public function getProperties() |
|
| 181 | + { |
|
| 182 | + return $this->properties; |
|
| 183 | + } |
|
| 184 | 184 | /** |
| 185 | - * Gets the name of the child class only |
|
| 186 | - * without the namespace |
|
| 187 | - * @var $className |
|
| 188 | - * @var $table |
|
| 189 | - * @return $table |
|
| 190 | - */ |
|
| 185 | + * Gets the name of the child class only |
|
| 186 | + * without the namespace |
|
| 187 | + * @var $className |
|
| 188 | + * @var $table |
|
| 189 | + * @return $table |
|
| 190 | + */ |
|
| 191 | 191 | public function getTableName() |
| 192 | 192 | { |
| 193 | 193 | $className = explode('\\', get_called_class()); |
@@ -195,22 +195,22 @@ discard block |
||
| 195 | 195 | return $table; |
| 196 | 196 | } |
| 197 | 197 | /** |
| 198 | - * returns a particular record |
|
| 199 | - * @param $id reps the record id |
|
| 200 | - * @param $connection initialised to null |
|
| 201 | - * @return object |
|
| 202 | - */ |
|
| 198 | + * returns a particular record |
|
| 199 | + * @param $id reps the record id |
|
| 200 | + * @param $connection initialised to null |
|
| 201 | + * @return object |
|
| 202 | + */ |
|
| 203 | 203 | public static function find($id) |
| 204 | 204 | { |
| 205 | 205 | $model = new static; |
| 206 | 206 | return $model->get($id); |
| 207 | 207 | } |
| 208 | 208 | /** |
| 209 | - * returns a particular record |
|
| 210 | - * @param $id reps the record id |
|
| 211 | - * @param $connection initialised to null |
|
| 212 | - * @return object |
|
| 213 | - */ |
|
| 209 | + * returns a particular record |
|
| 210 | + * @param $id reps the record id |
|
| 211 | + * @param $connection initialised to null |
|
| 212 | + * @return object |
|
| 213 | + */ |
|
| 214 | 214 | public function get($id) |
| 215 | 215 | { |
| 216 | 216 | $sql = "SELECT * FROM {$this->getTableName()} WHERE id={$id}"; |
@@ -239,8 +239,8 @@ discard block |
||
| 239 | 239 | |
| 240 | 240 | } |
| 241 | 241 | /** update table with instance properties |
| 242 | - * |
|
| 243 | - */ |
|
| 242 | + * |
|
| 243 | + */ |
|
| 244 | 244 | private function update() |
| 245 | 245 | { |
| 246 | 246 | $connection = $this->getConnection(); |
@@ -266,8 +266,8 @@ discard block |
||
| 266 | 266 | return $stmt->rowCount(); |
| 267 | 267 | } |
| 268 | 268 | /** |
| 269 | - * insert instance data into the table |
|
| 270 | - */ |
|
| 269 | + * insert instance data into the table |
|
| 270 | + */ |
|
| 271 | 271 | private function create() |
| 272 | 272 | { |
| 273 | 273 | $connection = $this->getConnection(); |
@@ -299,8 +299,8 @@ discard block |
||
| 299 | 299 | return $stmt->rowCount(); |
| 300 | 300 | } |
| 301 | 301 | /** |
| 302 | - * get db connection |
|
| 303 | - */ |
|
| 302 | + * get db connection |
|
| 303 | + */ |
|
| 304 | 304 | public function getConnection($connection = null) |
| 305 | 305 | { |
| 306 | 306 | if(is_null($connection)) |
@@ -309,10 +309,10 @@ discard block |
||
| 309 | 309 | } |
| 310 | 310 | } |
| 311 | 311 | /** |
| 312 | - * checks if the id exists |
|
| 313 | - * update if exist |
|
| 314 | - * create if not exist |
|
| 315 | - */ |
|
| 312 | + * checks if the id exists |
|
| 313 | + * update if exist |
|
| 314 | + * create if not exist |
|
| 315 | + */ |
|
| 316 | 316 | public function save() |
| 317 | 317 | { |
| 318 | 318 | if ($this->id) { |
@@ -322,10 +322,10 @@ discard block |
||
| 322 | 322 | } |
| 323 | 323 | } |
| 324 | 324 | /** |
| 325 | - * @param row reps record id |
|
| 326 | - * @param $connection initialised to null |
|
| 327 | - * @return boolean |
|
| 328 | - */ |
|
| 325 | + * @param row reps record id |
|
| 326 | + * @param $connection initialised to null |
|
| 327 | + * @return boolean |
|
| 328 | + */ |
|
| 329 | 329 | public static function destroy($id) |
| 330 | 330 | { |
| 331 | 331 | |
@@ -10,28 +10,28 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * Store instance of database connection used. |
| 13 | - * @var [type] |
|
| 14 | - */ |
|
| 13 | + * @var [type] |
|
| 14 | + */ |
|
| 15 | 15 | protected $databaseConnection; |
| 16 | 16 | |
| 17 | - public function __construct() |
|
| 17 | + public function __construct() |
|
| 18 | 18 | { |
| 19 | 19 | $this->databaseConnection = DatabaseConnection::getInstance()->databaseConnection; |
| 20 | 20 | //$databaseConnection->databaseConnection->connect(); |
| 21 | 21 | } |
| 22 | 22 | /** |
| 23 | - * @param string $key rep column name |
|
| 24 | - * @param string $val rep column value |
|
| 25 | - * sets into $propertie the $key => $value pairs |
|
| 26 | - */ |
|
| 23 | + * @param string $key rep column name |
|
| 24 | + * @param string $val rep column value |
|
| 25 | + * sets into $propertie the $key => $value pairs |
|
| 26 | + */ |
|
| 27 | 27 | public function __set($key, $val) |
| 28 | 28 | { |
| 29 | 29 | $this->properties[$key] = $val; |
| 30 | 30 | } |
| 31 | 31 | /** |
| 32 | - * @param string $key reps the column name |
|
| 33 | - * @return $key and $value |
|
| 34 | - */ |
|
| 32 | + * @param string $key reps the column name |
|
| 33 | + * @return $key and $value |
|
| 34 | + */ |
|
| 35 | 35 | public function __get($key) |
| 36 | 36 | { |
| 37 | 37 | return $this->properties[$key]; |
@@ -41,17 +41,17 @@ discard block |
||
| 41 | 41 | * |
| 42 | 42 | * @return array |
| 43 | 43 | */ |
| 44 | - public function getProperties() |
|
| 45 | - { |
|
| 46 | - return $this->properties; |
|
| 47 | - } |
|
| 44 | + public function getProperties() |
|
| 45 | + { |
|
| 46 | + return $this->properties; |
|
| 47 | + } |
|
| 48 | 48 | /** |
| 49 | - * Gets the name of the child class only |
|
| 50 | - * without the namespace |
|
| 51 | - * @var $className |
|
| 52 | - * @var $table |
|
| 53 | - * @return $table |
|
| 54 | - */ |
|
| 49 | + * Gets the name of the child class only |
|
| 50 | + * without the namespace |
|
| 51 | + * @var $className |
|
| 52 | + * @var $table |
|
| 53 | + * @return $table |
|
| 54 | + */ |
|
| 55 | 55 | public function getTableName() |
| 56 | 56 | { |
| 57 | 57 | $className = explode('\\', get_called_class()); |
@@ -59,22 +59,22 @@ discard block |
||
| 59 | 59 | return $table; |
| 60 | 60 | } |
| 61 | 61 | /** |
| 62 | - * returns a particular record |
|
| 63 | - * @param $id reps the record id |
|
| 64 | - * @param $connection initialised to null |
|
| 65 | - * @return object |
|
| 66 | - */ |
|
| 62 | + * returns a particular record |
|
| 63 | + * @param $id reps the record id |
|
| 64 | + * @param $connection initialised to null |
|
| 65 | + * @return object |
|
| 66 | + */ |
|
| 67 | 67 | public static function find($id) |
| 68 | 68 | { |
| 69 | 69 | $model = new static; |
| 70 | 70 | return $model->get($id); |
| 71 | 71 | } |
| 72 | 72 | /** |
| 73 | - * returns a particular record |
|
| 74 | - * @param $id reps the record id |
|
| 75 | - * @param $connection initialised to null |
|
| 76 | - * @return object |
|
| 77 | - */ |
|
| 73 | + * returns a particular record |
|
| 74 | + * @param $id reps the record id |
|
| 75 | + * @param $connection initialised to null |
|
| 76 | + * @return object |
|
| 77 | + */ |
|
| 78 | 78 | public function get($id) |
| 79 | 79 | { |
| 80 | 80 | $sql = "SELECT * FROM {$this->getTableName()} WHERE id={$id}"; |
@@ -103,8 +103,8 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | } |
| 105 | 105 | /** update table with instance properties |
| 106 | - * |
|
| 107 | - */ |
|
| 106 | + * |
|
| 107 | + */ |
|
| 108 | 108 | private function update() |
| 109 | 109 | { |
| 110 | 110 | $connection = $this->getConnection(); |
@@ -130,8 +130,8 @@ discard block |
||
| 130 | 130 | return $stmt->rowCount(); |
| 131 | 131 | } |
| 132 | 132 | /** |
| 133 | - * insert instance data into the table |
|
| 134 | - */ |
|
| 133 | + * insert instance data into the table |
|
| 134 | + */ |
|
| 135 | 135 | private function create() |
| 136 | 136 | { |
| 137 | 137 | $connection = $this->getConnection(); |
@@ -163,8 +163,8 @@ discard block |
||
| 163 | 163 | return $stmt->rowCount(); |
| 164 | 164 | } |
| 165 | 165 | /** |
| 166 | - * get db connection |
|
| 167 | - */ |
|
| 166 | + * get db connection |
|
| 167 | + */ |
|
| 168 | 168 | public function getConnection($connection = null) |
| 169 | 169 | { |
| 170 | 170 | if(is_null($connection)) |
@@ -173,10 +173,10 @@ discard block |
||
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | /** |
| 176 | - * checks if the id exists |
|
| 177 | - * update if exist |
|
| 178 | - * create if not exist |
|
| 179 | - */ |
|
| 176 | + * checks if the id exists |
|
| 177 | + * update if exist |
|
| 178 | + * create if not exist |
|
| 179 | + */ |
|
| 180 | 180 | public function save() |
| 181 | 181 | { |
| 182 | 182 | if ($this->id) { |
@@ -186,10 +186,10 @@ discard block |
||
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | /** |
| 189 | - * @param row reps record id |
|
| 190 | - * @param $connection initialised to null |
|
| 191 | - * @return boolean |
|
| 192 | - */ |
|
| 189 | + * @param row reps record id |
|
| 190 | + * @param $connection initialised to null |
|
| 191 | + * @return boolean |
|
| 192 | + */ |
|
| 193 | 193 | public static function destroy($id) |
| 194 | 194 | { |
| 195 | 195 | |
@@ -1,10 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | abstract class A { |
| 4 | - function __construct() |
|
| 5 | - { |
|
| 6 | - echo "Here\n"; |
|
| 7 | - } |
|
| 4 | + function __construct() |
|
| 5 | + { |
|
| 6 | + echo "Here\n"; |
|
| 7 | + } |
|
| 8 | 8 | |
| 9 | 9 | } |
| 10 | 10 | |
@@ -4,11 +4,11 @@ |
||
| 4 | 4 | |
| 5 | 5 | class DatabaseConnectionStringFactoryTest extends PHPUnit_Framework_TestCase |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * The instance of DatabaseConnectionStringFactory used in the test. |
|
| 9 | - * |
|
| 10 | - * @var Pyjac\ORM\DatabaseConnectionStringFactory |
|
| 11 | - */ |
|
| 7 | + /** |
|
| 8 | + * The instance of DatabaseConnectionStringFactory used in the test. |
|
| 9 | + * |
|
| 10 | + * @var Pyjac\ORM\DatabaseConnectionStringFactory |
|
| 11 | + */ |
|
| 12 | 12 | protected $openSourceEvangelistFactory; |
| 13 | 13 | |
| 14 | 14 | /** |
@@ -2,28 +2,28 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | |
| 4 | 4 | interface ModelInterface { |
| 5 | - /** |
|
| 6 | - * Get all models from database. |
|
| 7 | - * |
|
| 8 | - * @return array |
|
| 9 | - */ |
|
| 10 | - function static getAll(); |
|
| 11 | - |
|
| 12 | - /** |
|
| 13 | - * Find model with the specified id. |
|
| 14 | - */ |
|
| 15 | - function static find($id); |
|
| 16 | - |
|
| 17 | - /** |
|
| 18 | - * Delete model with the specified id. |
|
| 19 | - * |
|
| 20 | - */ |
|
| 21 | - function static destroy($id); |
|
| 5 | + /** |
|
| 6 | + * Get all models from database. |
|
| 7 | + * |
|
| 8 | + * @return array |
|
| 9 | + */ |
|
| 10 | + function static getAll(); |
|
| 11 | + |
|
| 12 | + /** |
|
| 13 | + * Find model with the specified id. |
|
| 14 | + */ |
|
| 15 | + function static find($id); |
|
| 16 | + |
|
| 17 | + /** |
|
| 18 | + * Delete model with the specified id. |
|
| 19 | + * |
|
| 20 | + */ |
|
| 21 | + function static destroy($id); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | abstract Model { |
| 25 | 25 | |
| 26 | - /** |
|
| 26 | + /** |
|
| 27 | 27 | * The connection name for the model. |
| 28 | 28 | * |
| 29 | 29 | * @var string |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | class Connection { |
| 45 | 45 | |
| 46 | - /** |
|
| 46 | + /** |
|
| 47 | 47 | * The current globally used instance. |
| 48 | 48 | * |
| 49 | 49 | * @var object |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | private $error; |
| 60 | 60 | |
| 61 | 61 | public function __construct(){ |
| 62 | - $config = parse_ini_file('config.ini'); |
|
| 62 | + $config = parse_ini_file('config.ini'); |
|
| 63 | 63 | // Set DSN |
| 64 | 64 | $dsn = 'mysql:host=' . $this->host . ';dbname=' . $this->dbname; |
| 65 | 65 | // Set options |
@@ -81,10 +81,10 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | try { |
| 83 | 83 | |
| 84 | - $dbh = new PDO('mysql:host=localhost;dbname=potatoORM', 'homestead', 'secret'); |
|
| 85 | - foreach($dbh->query('SELECT * from test') as $row) { |
|
| 86 | - print_r($row); |
|
| 87 | - } |
|
| 84 | + $dbh = new PDO('mysql:host=localhost;dbname=potatoORM', 'homestead', 'secret'); |
|
| 85 | + foreach($dbh->query('SELECT * from test') as $row) { |
|
| 86 | + print_r($row); |
|
| 87 | + } |
|
| 88 | 88 | } catch (PDOException $e) { |
| 89 | 89 | print "Error!: " . $e->getMessage() . "<br/>"; |
| 90 | 90 | die(); |
@@ -109,12 +109,12 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | |
| 111 | 111 | |
| 112 | - function __construct() |
|
| 113 | - { |
|
| 114 | - /** |
|
| 115 | - * Load the environment variables |
|
| 116 | - * @return connection object |
|
| 117 | - */ |
|
| 112 | + function __construct() |
|
| 113 | + { |
|
| 114 | + /** |
|
| 115 | + * Load the environment variables |
|
| 116 | + * @return connection object |
|
| 117 | + */ |
|
| 118 | 118 | $this->loadDotenv(); |
| 119 | 119 | |
| 120 | 120 | $this->database = getenv('DB_DATABASE'); |
@@ -123,10 +123,10 @@ discard block |
||
| 123 | 123 | $this->password = getenv('DB_PASSWORD'); |
| 124 | 124 | $this->driver = getenv('DB_CONNECTION'); |
| 125 | 125 | |
| 126 | - } |
|
| 127 | - /** |
|
| 128 | - * use vlucas dotenv to access the .env file |
|
| 129 | - **/ |
|
| 126 | + } |
|
| 127 | + /** |
|
| 128 | + * use vlucas dotenv to access the .env file |
|
| 129 | + **/ |
|
| 130 | 130 | protected function loadDotenv() |
| 131 | 131 | { |
| 132 | 132 | if(getenv('APP_ENV') !== 'production') |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | |
| 392 | 392 | class Helpers { |
| 393 | 393 | |
| 394 | - /** |
|
| 394 | + /** |
|
| 395 | 395 | * Determine if a given string contains a given substring. |
| 396 | 396 | * |
| 397 | 397 | * @param string $haystack |