@@ -11,7 +11,7 @@ |
||
11 | 11 | use app\framework\Component\Routing\Router; |
12 | 12 | |
13 | 13 | Router::get("/", function() { |
14 | - view("welcome", ["version" => version()]); |
|
14 | + view("welcome", [ "version" => version() ]); |
|
15 | 15 | }); |
16 | 16 | Router::get("/home", function() { |
17 | 17 | view("home"); |
@@ -1,15 +1,15 @@ discard block |
||
1 | 1 | <?php |
2 | -if(! function_exists("dd")) { |
|
2 | +if (!function_exists("dd")) { |
|
3 | 3 | /** |
4 | 4 | * Little helper called dump and die |
5 | 5 | * @param $val |
6 | 6 | */ |
7 | 7 | function dd($val) { |
8 | - var_dump($val);die; |
|
8 | + var_dump($val); die; |
|
9 | 9 | } |
10 | 10 | } |
11 | 11 | |
12 | -if(! function_exists("pathTo")) { |
|
12 | +if (!function_exists("pathTo")) { |
|
13 | 13 | /** |
14 | 14 | * Easy function to get the path to the project + if you want an directory in it. |
15 | 15 | * |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | } |
22 | 22 | } |
23 | 23 | |
24 | -if(! function_exists("view")) { |
|
24 | +if (!function_exists("view")) { |
|
25 | 25 | /** |
26 | 26 | * Get the evaluated view contents for the given view. |
27 | 27 | * |
@@ -29,14 +29,14 @@ discard block |
||
29 | 29 | * @param array $data Data to set values in template file |
30 | 30 | * @return \app\framework\Component\View\View|string |
31 | 31 | */ |
32 | - function view($view = null, $data = []) { |
|
33 | - $data['auth'] = new \app\framework\Component\Auth\Auth; |
|
32 | + function view($view = null, $data = [ ]) { |
|
33 | + $data[ 'auth' ] = new \app\framework\Component\Auth\Auth; |
|
34 | 34 | $View = new \app\framework\Component\View\View($view, $data); |
35 | 35 | return $View->render(); |
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | -if(! function_exists("app")) { |
|
39 | +if (!function_exists("app")) { |
|
40 | 40 | /** |
41 | 41 | * Used to easily call Methods from classes without manually set |
42 | 42 | * locally Instances of them. |
@@ -45,12 +45,12 @@ discard block |
||
45 | 45 | * @param array $param To declare what parameter shall be passed to the method |
46 | 46 | * @return mixed |
47 | 47 | */ |
48 | - function app($classMethod, $param = []) { |
|
49 | - return $GLOBALS["App"]->call($classMethod, $param); |
|
48 | + function app($classMethod, $param = [ ]) { |
|
49 | + return $GLOBALS[ "App" ]->call($classMethod, $param); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | -if(! function_exists("url")) { |
|
53 | +if (!function_exists("url")) { |
|
54 | 54 | /** |
55 | 55 | * Basically completes just the the url |
56 | 56 | * e.g. /test to yourexample.site/test |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | * @return string |
63 | 63 | */ |
64 | 64 | function url($path) { |
65 | - return $_SERVER['HTTP_HOST'].$path; |
|
65 | + return $_SERVER[ 'HTTP_HOST' ].$path; |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | -if(! function_exists("getStringBetween")) { |
|
69 | +if (!function_exists("getStringBetween")) { |
|
70 | 70 | /** |
71 | 71 | * This is a handy little function to strip out a string between |
72 | 72 | * two specified pieces of text. This could be used to parse |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @return bool|string |
79 | 79 | */ |
80 | 80 | function getStringBetween($string, $start, $end) { |
81 | - $string = ' ' . $string; |
|
81 | + $string = ' '.$string; |
|
82 | 82 | $ini = strpos($string, $start); |
83 | 83 | if ($ini == 0) return ''; |
84 | 84 | $ini += strlen($start); |
@@ -87,13 +87,13 @@ discard block |
||
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | -if(! function_exists("handle")) { |
|
91 | - function handle( $e) { |
|
90 | +if (!function_exists("handle")) { |
|
91 | + function handle($e) { |
|
92 | 92 | \app\framework\Component\Exception\Handler::getInstance()->handler($e); |
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | -if(! function_exists("arr")) { |
|
96 | +if (!function_exists("arr")) { |
|
97 | 97 | /** |
98 | 98 | * Create an ArrayObject from array |
99 | 99 | * @param array $arr |
@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | -if(! function_exists("str")) { |
|
107 | +if (!function_exists("str")) { |
|
108 | 108 | function str($str) { |
109 | 109 | return new \app\framework\Component\StdLib\StdObject\StringObject\StringObject($str); |
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
113 | -if(! function_exists("encrypt")) { |
|
113 | +if (!function_exists("encrypt")) { |
|
114 | 114 | /** |
115 | 115 | * Encrypt the given value. |
116 | 116 | * |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | \app\framework\Component\Config\Config::getInstance()->get("CrypKey") |
125 | 125 | ); |
126 | 126 | |
127 | - return $Encryptor->encrypt($value, $serialize ); |
|
127 | + return $Encryptor->encrypt($value, $serialize); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
131 | -if(! function_exists("decrypt")) { |
|
131 | +if (!function_exists("decrypt")) { |
|
132 | 132 | /** |
133 | 133 | * Decrypt the given value. |
134 | 134 | * |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | \app\framework\Component\Config\Config::getInstance()->get("CrypKey") |
143 | 143 | ); |
144 | 144 | |
145 | - return $Encryptor->decrypt($value, $unserialize ); |
|
145 | + return $Encryptor->decrypt($value, $unserialize); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
149 | -if(! function_exists("version")) { |
|
149 | +if (!function_exists("version")) { |
|
150 | 150 | /** |
151 | 151 | * @return string version as written in config/app.php |
152 | 152 | */ |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
158 | -if(! function_exists("isDebug")) { |
|
158 | +if (!function_exists("isDebug")) { |
|
159 | 159 | function isDebug() { |
160 | 160 | return \app\framework\Component\Config\Config::getInstance()->get("debug", "app"); |
161 | 161 | } |
@@ -46,17 +46,17 @@ |
||
46 | 46 | protected function execute(InputInterface $input, ConsoleOutput $output) |
47 | 47 | { |
48 | 48 | $migrationName = $input->getArgument("name"); |
49 | - $tableName = $input->getArgument("tableName"); |
|
50 | - $connectionName = $input->getArgument("connectionName"); |
|
49 | + $tableName = $input->getArgument("tableName"); |
|
50 | + $connectionName = $input->getArgument("connectionName"); |
|
51 | 51 | |
52 | 52 | $template = str_replace("§NAME§", $migrationName, $this->template); |
53 | 53 | |
54 | - if(isset($connectionName)) |
|
54 | + if (isset($connectionName)) |
|
55 | 55 | $template = str_replace("§CONNECTION§", 'protected $connection = "'.$connectionName.'";', $template); |
56 | 56 | else |
57 | 57 | $template = str_replace("§CONNECTION§", '', $template); |
58 | 58 | |
59 | - if(isset($tableName)) |
|
59 | + if (isset($tableName)) |
|
60 | 60 | $template = str_replace("§TABLE§", 'protected $table = "'.$tableName.'";', $template); |
61 | 61 | else |
62 | 62 | $template = str_replace("§TABLE§", '', $template); |
@@ -51,15 +51,17 @@ |
||
51 | 51 | |
52 | 52 | $template = str_replace("§NAME§", $migrationName, $this->template); |
53 | 53 | |
54 | - if(isset($connectionName)) |
|
55 | - $template = str_replace("§CONNECTION§", 'protected $connection = "'.$connectionName.'";', $template); |
|
56 | - else |
|
57 | - $template = str_replace("§CONNECTION§", '', $template); |
|
54 | + if(isset($connectionName)) { |
|
55 | + $template = str_replace("§CONNECTION§", 'protected $connection = "'.$connectionName.'";', $template); |
|
56 | + } else { |
|
57 | + $template = str_replace("§CONNECTION§", '', $template); |
|
58 | + } |
|
58 | 59 | |
59 | - if(isset($tableName)) |
|
60 | - $template = str_replace("§TABLE§", 'protected $table = "'.$tableName.'";', $template); |
|
61 | - else |
|
62 | - $template = str_replace("§TABLE§", '', $template); |
|
60 | + if(isset($tableName)) { |
|
61 | + $template = str_replace("§TABLE§", 'protected $table = "'.$tableName.'";', $template); |
|
62 | + } else { |
|
63 | + $template = str_replace("§TABLE§", '', $template); |
|
64 | + } |
|
63 | 65 | |
64 | 66 | $File = new File($migrationName.".php", new Storage("model")); |
65 | 67 | //$File->setContents($template); |
@@ -72,7 +72,7 @@ |
||
72 | 72 | try { |
73 | 73 | $File = new File($newMigrationName.".php", new Storage("migrations")); |
74 | 74 | |
75 | - if(fopen($File->getAbsolutePath(), "w")) { |
|
75 | + if (fopen($File->getAbsolutePath(), "w")) { |
|
76 | 76 | $tempDefaultCommand = str_replace("§NAME§", $newMigrationName, $this->template); |
77 | 77 | $tempDefaultCommand = str_replace("§connection§", $connection, $tempDefaultCommand); |
78 | 78 | file_put_contents($File->getAbsolutePath(), $tempDefaultCommand); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | /** |
24 | 24 | * @var Migration[] $migrations |
25 | 25 | */ |
26 | - private $migrations = []; |
|
26 | + private $migrations = [ ]; |
|
27 | 27 | |
28 | 28 | protected function configure() |
29 | 29 | { |
@@ -59,24 +59,24 @@ discard block |
||
59 | 59 | private function setMigrations(ConsoleOutput $output) |
60 | 60 | { |
61 | 61 | // get all migrations |
62 | - $classes = []; |
|
62 | + $classes = [ ]; |
|
63 | 63 | $namespace = $this->namespace; |
64 | 64 | |
65 | - $path = str_replace("\\","/", $namespace); |
|
65 | + $path = str_replace("\\", "/", $namespace); |
|
66 | 66 | $filesInNamespace = new ArrayObject(scandir(ROOT_PATH."/".$path."/")); |
67 | 67 | $filesInNamespace->removeFirst()->removeFirst(); |
68 | 68 | |
69 | - for ($i = 0; $i <= $filesInNamespace->count()-1; $i++) |
|
70 | - $filesInNamespace->key($i, explode(".php", $filesInNamespace->key($i))[0]); |
|
69 | + for ($i = 0; $i <= $filesInNamespace->count() - 1; $i++) |
|
70 | + $filesInNamespace->key($i, explode(".php", $filesInNamespace->key($i))[ 0 ]); |
|
71 | 71 | |
72 | 72 | foreach ($filesInNamespace->val() as $value) { |
73 | 73 | $class = $namespace.$value; |
74 | - if(class_exists($class) && is_subclass_of($class,'app\framework\Component\Database\Migrations\Migration')) |
|
75 | - $classes[$value] = new $class(); |
|
74 | + if (class_exists($class) && is_subclass_of($class, 'app\framework\Component\Database\Migrations\Migration')) |
|
75 | + $classes[ $value ] = new $class(); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | // tell user so if there are no migrations |
79 | - if($classes == []) { |
|
79 | + if ($classes == [ ]) { |
|
80 | 80 | $output->writeln("No migrations found! You can Create migrations via the make:migration command."); |
81 | 81 | } else { |
82 | 82 | $this->migrations = $classes; |
@@ -87,15 +87,15 @@ discard block |
||
87 | 87 | { |
88 | 88 | $migrationInstance = null; |
89 | 89 | $class = $this->namespace.$migration; |
90 | - if(class_exists($class) && is_subclass_of($class,'app\framework\Component\Database\Migrations\Migration')) |
|
90 | + if (class_exists($class) && is_subclass_of($class, 'app\framework\Component\Database\Migrations\Migration')) |
|
91 | 91 | $migrationInstance = new $class(); |
92 | 92 | |
93 | - if($migrationInstance == null) { |
|
93 | + if ($migrationInstance == null) { |
|
94 | 94 | $output->writeln("Migration not found"); |
95 | 95 | } else { |
96 | 96 | // to make sure that only one element is in array |
97 | - $this->migrations = []; |
|
98 | - $this->migrations[] = $migrationInstance; |
|
97 | + $this->migrations = [ ]; |
|
98 | + $this->migrations[ ] = $migrationInstance; |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | } |
@@ -52,8 +52,9 @@ discard block |
||
52 | 52 | $class->up(); |
53 | 53 | } |
54 | 54 | |
55 | - if (count($this->migrations) > 0) |
|
56 | - $output->writeln("Migration successful"); |
|
55 | + if (count($this->migrations) > 0) { |
|
56 | + $output->writeln("Migration successful"); |
|
57 | + } |
|
57 | 58 | } |
58 | 59 | |
59 | 60 | private function setMigrations(ConsoleOutput $output) |
@@ -66,13 +67,15 @@ discard block |
||
66 | 67 | $filesInNamespace = new ArrayObject(scandir(ROOT_PATH."/".$path."/")); |
67 | 68 | $filesInNamespace->removeFirst()->removeFirst(); |
68 | 69 | |
69 | - for ($i = 0; $i <= $filesInNamespace->count()-1; $i++) |
|
70 | - $filesInNamespace->key($i, explode(".php", $filesInNamespace->key($i))[0]); |
|
70 | + for ($i = 0; $i <= $filesInNamespace->count()-1; $i++) { |
|
71 | + $filesInNamespace->key($i, explode(".php", $filesInNamespace->key($i))[0]); |
|
72 | + } |
|
71 | 73 | |
72 | 74 | foreach ($filesInNamespace->val() as $value) { |
73 | 75 | $class = $namespace.$value; |
74 | - if(class_exists($class) && is_subclass_of($class,'app\framework\Component\Database\Migrations\Migration')) |
|
75 | - $classes[$value] = new $class(); |
|
76 | + if(class_exists($class) && is_subclass_of($class,'app\framework\Component\Database\Migrations\Migration')) { |
|
77 | + $classes[$value] = new $class(); |
|
78 | + } |
|
76 | 79 | } |
77 | 80 | |
78 | 81 | // tell user so if there are no migrations |
@@ -87,8 +90,9 @@ discard block |
||
87 | 90 | { |
88 | 91 | $migrationInstance = null; |
89 | 92 | $class = $this->namespace.$migration; |
90 | - if(class_exists($class) && is_subclass_of($class,'app\framework\Component\Database\Migrations\Migration')) |
|
91 | - $migrationInstance = new $class(); |
|
93 | + if(class_exists($class) && is_subclass_of($class,'app\framework\Component\Database\Migrations\Migration')) { |
|
94 | + $migrationInstance = new $class(); |
|
95 | + } |
|
92 | 96 | |
93 | 97 | if($migrationInstance == null) { |
94 | 98 | $output->writeln("Migration not found"); |
@@ -54,14 +54,14 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @var array |
56 | 56 | */ |
57 | - protected $config = []; |
|
57 | + protected $config = [ ]; |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * All of the queries run against the connection. |
61 | 61 | * |
62 | 62 | * @var array |
63 | 63 | */ |
64 | - protected $queryLog = []; |
|
64 | + protected $queryLog = [ ]; |
|
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Indicates whether queries are being logged. |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | protected $loggingQueries = true; |
72 | 72 | |
73 | - public function __construct(Pdo $pdo, string $database = '', string $name = '', array $conf = []) |
|
73 | + public function __construct(Pdo $pdo, string $database = '', string $name = '', array $conf = [ ]) |
|
74 | 74 | { |
75 | 75 | $this->pdo = $pdo; |
76 | 76 | $this->name = $name; |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function flushQueryLog() |
102 | 102 | { |
103 | - $this->queryLog = []; |
|
103 | + $this->queryLog = [ ]; |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -160,12 +160,12 @@ discard block |
||
160 | 160 | |
161 | 161 | public function getDriver() |
162 | 162 | { |
163 | - return $this->config['driver']; |
|
163 | + return $this->config[ 'driver' ]; |
|
164 | 164 | } |
165 | 165 | |
166 | - public function select(string $query, array $bindings = [], $table = "") |
|
166 | + public function select(string $query, array $bindings = [ ], $table = "") |
|
167 | 167 | { |
168 | - return $this->run($query, $bindings, function ($me, $query, $bindings) use ($table) { |
|
168 | + return $this->run($query, $bindings, function($me, $query, $bindings) use ($table) { |
|
169 | 169 | // For select statements, we'll simply execute the query and return an array |
170 | 170 | // of the database result set. Each element in the array will be a single |
171 | 171 | // row from the database table, and will either be an array or objects. |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * @param array $bindings |
186 | 186 | * @return bool |
187 | 187 | */ |
188 | - public function insert($query, $bindings = []) |
|
188 | + public function insert($query, $bindings = [ ]) |
|
189 | 189 | { |
190 | 190 | return $this->statement($query, $bindings); |
191 | 191 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * @param array $bindings |
198 | 198 | * @return int |
199 | 199 | */ |
200 | - public function update($query, $bindings = []) |
|
200 | + public function update($query, $bindings = [ ]) |
|
201 | 201 | { |
202 | 202 | return $this->affectingStatement($query, $bindings); |
203 | 203 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @param array $bindings |
210 | 210 | * @return int |
211 | 211 | */ |
212 | - public function delete($query, $bindings = []) |
|
212 | + public function delete($query, $bindings = [ ]) |
|
213 | 213 | { |
214 | 214 | return $this->affectingStatement($query, $bindings); |
215 | 215 | } |
@@ -221,9 +221,9 @@ discard block |
||
221 | 221 | * @param array $bindings |
222 | 222 | * @return bool |
223 | 223 | */ |
224 | - public function statement($query, $bindings = []) |
|
224 | + public function statement($query, $bindings = [ ]) |
|
225 | 225 | { |
226 | - return $this->run($query, $bindings, function ($me, $query, $bindings) { |
|
226 | + return $this->run($query, $bindings, function($me, $query, $bindings) { |
|
227 | 227 | return $me->pdo->prepare($query)->execute($bindings); |
228 | 228 | }); |
229 | 229 | } |
@@ -235,9 +235,9 @@ discard block |
||
235 | 235 | * @param array $bindings |
236 | 236 | * @return int |
237 | 237 | */ |
238 | - public function affectingStatement($query, $bindings = []) |
|
238 | + public function affectingStatement($query, $bindings = [ ]) |
|
239 | 239 | { |
240 | - return $this->run($query, $bindings, function ($me, $query, $bindings) { |
|
240 | + return $this->run($query, $bindings, function($me, $query, $bindings) { |
|
241 | 241 | |
242 | 242 | // For update or delete statements, we want to get the number of rows affected |
243 | 243 | // by the statement and return that back to the developer. We'll first need |
@@ -318,12 +318,12 @@ discard block |
||
318 | 318 | { |
319 | 319 | $this->eventManager()->fire("ff.database.query_execution"); |
320 | 320 | |
321 | - if($this->loggingQueries) { |
|
322 | - $logEntry['startTime'] = $stopwatchEvent->getStartTime(); |
|
323 | - $logEntry['query'] = $query; |
|
324 | - $logEntry['executionTime'] = $stopwatchEvent->getDuration(); |
|
321 | + if ($this->loggingQueries) { |
|
322 | + $logEntry[ 'startTime' ] = $stopwatchEvent->getStartTime(); |
|
323 | + $logEntry[ 'query' ] = $query; |
|
324 | + $logEntry[ 'executionTime' ] = $stopwatchEvent->getDuration(); |
|
325 | 325 | |
326 | - $this->queryLog[] = $logEntry; |
|
326 | + $this->queryLog[ ] = $logEntry; |
|
327 | 327 | } |
328 | 328 | } |
329 | 329 | |
@@ -335,12 +335,12 @@ discard block |
||
335 | 335 | */ |
336 | 336 | public function fetch(PDOStatement $statement) |
337 | 337 | { |
338 | - $result = []; |
|
338 | + $result = [ ]; |
|
339 | 339 | $statement = $statement->fetchAll(PDO::FETCH_ASSOC); |
340 | 340 | |
341 | 341 | foreach ($statement as $key => $value) { |
342 | - $result[$key] = new Model($this); |
|
343 | - $result[$key]->fillData($value); |
|
342 | + $result[ $key ] = new Model($this); |
|
343 | + $result[ $key ]->fillData($value); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | return $result; |
@@ -42,14 +42,14 @@ discard block |
||
42 | 42 | /** |
43 | 43 | * @var Connection[] |
44 | 44 | */ |
45 | - private $connections = []; |
|
45 | + private $connections = [ ]; |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Contains the connection configuration information's |
49 | 49 | * |
50 | 50 | * @var array |
51 | 51 | */ |
52 | - private $configuration = []; |
|
52 | + private $configuration = [ ]; |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * @param string|null $name |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | public function get(string $name = null): Connection |
60 | 60 | { |
61 | 61 | // check if connection with $name was already instantiated if yes return |
62 | - if(isset($this->connections[$name])) { |
|
63 | - return $this->connections[$name]; |
|
62 | + if (isset($this->connections[ $name ])) { |
|
63 | + return $this->connections[ $name ]; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | // otherwise create and save in $connections |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $this->getConnectionName($name) |
84 | 84 | ); |
85 | 85 | |
86 | - $this->connections[$name] = $connection; |
|
86 | + $this->connections[ $name ] = $connection; |
|
87 | 87 | |
88 | 88 | return $connection; |
89 | 89 | } |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | private function extractConfig() |
95 | 95 | { |
96 | 96 | $connByConfig = Config::getInstance()->get("connections"); |
97 | - $config = []; |
|
97 | + $config = [ ]; |
|
98 | 98 | |
99 | 99 | foreach ($connByConfig as $name => $con) { |
100 | - $config[$name] = $this->parseConfig($con); |
|
100 | + $config[ $name ] = $this->parseConfig($con); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | $this->configuration = $config; |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | return key($config); |
118 | 118 | } |
119 | 119 | |
120 | - if (isset($config[$name])) { |
|
120 | + if (isset($config[ $name ])) { |
|
121 | 121 | return $name; |
122 | 122 | } else { |
123 | 123 | // if conf not found Exception |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | private function parseConfig(array $config): array |
135 | 135 | { |
136 | 136 | // make sure that the default config elements exist to prevent an undefined index warning |
137 | - foreach(self::defaultConfigElements as $configElement) { |
|
138 | - if(!array_key_exists($configElement, $config)) { |
|
139 | - $config[$configElement]; |
|
137 | + foreach (self::defaultConfigElements as $configElement) { |
|
138 | + if (!array_key_exists($configElement, $config)) { |
|
139 | + $config[ $configElement ]; |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
@@ -153,9 +153,9 @@ discard block |
||
153 | 153 | { |
154 | 154 | $config = $this->configuration; |
155 | 155 | |
156 | - $Pdo = $this->createPdoInstance($config[$name]); |
|
156 | + $Pdo = $this->createPdoInstance($config[ $name ]); |
|
157 | 157 | |
158 | - return $this->createConnection($Pdo, $config[$name]['database'], $name, $config); |
|
158 | + return $this->createConnection($Pdo, $config[ $name ][ 'database' ], $name, $config); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | { |
167 | 167 | $dsn = ""; |
168 | 168 | |
169 | - switch ($config['driver']) { |
|
169 | + switch ($config[ 'driver' ]) { |
|
170 | 170 | case Driver::MariaDB: |
171 | 171 | case Driver::MySql: |
172 | 172 | $dsn = Driver::mysql($config); |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | // break; |
194 | 194 | } |
195 | 195 | |
196 | - return new PDO($dsn, $config['username'], $config['password']); |
|
196 | + return new PDO($dsn, $config[ 'username' ], $config[ 'password' ]); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * @param array $config |
204 | 204 | * @return Connection |
205 | 205 | */ |
206 | - private function createConnection(PDO $Pdo, $database = "", string $name = '', array $config = []) |
|
206 | + private function createConnection(PDO $Pdo, $database = "", string $name = '', array $config = [ ]) |
|
207 | 207 | { |
208 | 208 | return new Connection($Pdo, $database, $name, $config); |
209 | 209 | } |
@@ -76,14 +76,14 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @var array |
78 | 78 | */ |
79 | - protected $attributes = []; |
|
79 | + protected $attributes = [ ]; |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * The model attribute's original state. |
83 | 83 | * |
84 | 84 | * @var array |
85 | 85 | */ |
86 | - protected $original = []; |
|
86 | + protected $original = [ ]; |
|
87 | 87 | |
88 | 88 | /** |
89 | 89 | * The number of models to return for pagination. |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * Model constructor. |
119 | 119 | * @param array $attributes |
120 | 120 | */ |
121 | - public function __construct(array $attributes = []) |
|
121 | + public function __construct(array $attributes = [ ]) |
|
122 | 122 | { |
123 | 123 | $this->bootIfNotBooted(); |
124 | 124 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public function bootIfNotBooted() |
139 | 139 | { |
140 | - if (! self::$isBooted) { |
|
140 | + if (!self::$isBooted) { |
|
141 | 141 | self::boot(); |
142 | 142 | |
143 | 143 | self::$isBooted = true; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public function syncOriginalAttribute($attribute) |
166 | 166 | { |
167 | - $this->original[$attribute] = $this->attributes[$attribute]; |
|
167 | + $this->original[ $attribute ] = $this->attributes[ $attribute ]; |
|
168 | 168 | |
169 | 169 | return $this; |
170 | 170 | } |
@@ -282,13 +282,13 @@ discard block |
||
282 | 282 | * @param array $columns |
283 | 283 | * @return mixed |
284 | 284 | */ |
285 | - public static function all(array $columns = ['*']) |
|
285 | + public static function all(array $columns = [ '*' ]) |
|
286 | 286 | { |
287 | 287 | $instance = new static(); |
288 | 288 | /** @var ArrayObject $result */ |
289 | 289 | $result = $instance->newQuery()->get($columns); |
290 | 290 | |
291 | - $result->map(function ($item) { |
|
291 | + $result->map(function($item) { |
|
292 | 292 | $item->exists = true; |
293 | 293 | }); |
294 | 294 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | $instance = new static(); |
305 | 305 | $result = $instance->newQuery()->find($id); |
306 | 306 | |
307 | - if (! is_null($result)) { |
|
307 | + if (!is_null($result)) { |
|
308 | 308 | $result->exists = true; |
309 | 309 | } |
310 | 310 | |
@@ -340,8 +340,8 @@ discard block |
||
340 | 340 | { |
341 | 341 | $instance = new static(); |
342 | 342 | |
343 | - if (! is_array($id)) { |
|
344 | - $id = [$id]; |
|
343 | + if (!is_array($id)) { |
|
344 | + $id = [ $id ]; |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | return $instance->newQuery()->remove($id); |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | */ |
372 | 372 | public function setAttribute($key, $value) |
373 | 373 | { |
374 | - $this->attributes[$key] = $value; |
|
374 | + $this->attributes[ $key ] = $value; |
|
375 | 375 | |
376 | 376 | return $this; |
377 | 377 | } |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | */ |
540 | 540 | public function offsetExists($offset) |
541 | 541 | { |
542 | - return isset($this->attributes[$offset]); |
|
542 | + return isset($this->attributes[ $offset ]); |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | /** |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | */ |
554 | 554 | public function offsetGet($offset) |
555 | 555 | { |
556 | - return $this->attributes[$offset]; |
|
556 | + return $this->attributes[ $offset ]; |
|
557 | 557 | } |
558 | 558 | |
559 | 559 | /** |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | */ |
571 | 571 | public function offsetSet($offset, $value) |
572 | 572 | { |
573 | - $this->attributes[$offset] = $value; |
|
573 | + $this->attributes[ $offset ] = $value; |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | /** |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | */ |
585 | 585 | public function offsetUnset($offset) |
586 | 586 | { |
587 | - unset($this->attributes[$offset]); |
|
587 | + unset($this->attributes[ $offset ]); |
|
588 | 588 | } |
589 | 589 | |
590 | 590 | /** |
@@ -653,11 +653,11 @@ discard block |
||
653 | 653 | { |
654 | 654 | $time = $this->freshTimestamp(); |
655 | 655 | |
656 | - if (! is_null(static::UPDATED_AT) ) { |
|
656 | + if (!is_null(static::UPDATED_AT)) { |
|
657 | 657 | $this->setUpdatedAt($time); |
658 | 658 | } |
659 | 659 | |
660 | - if (! is_null(static::CREATED_AT)) { |
|
660 | + if (!is_null(static::CREATED_AT)) { |
|
661 | 661 | $this->setCreatedAt($time); |
662 | 662 | } |
663 | 663 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | ->from($this->model->getTable()); |
103 | 103 | |
104 | 104 | if (!is_array($id)) { |
105 | - $id = [$id]; |
|
105 | + $id = [ $id ]; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | foreach ($id as $item) { |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | */ |
175 | 175 | public function __call($name, $arguments) |
176 | 176 | { |
177 | - if(in_array($name, $this->passThru)) { |
|
178 | - return call_user_func_array([$this->fromTable(), $name], $arguments); |
|
177 | + if (in_array($name, $this->passThru)) { |
|
178 | + return call_user_func_array([ $this->fromTable(), $name ], $arguments); |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | } |