@@ -8,6 +8,6 @@ |
||
| 8 | 8 | { |
| 9 | 9 | public function __construct() |
| 10 | 10 | { |
| 11 | - parent::__construct("users", ["first_name", "last_name"]); |
|
| 11 | + parent::__construct("users", [ "first_name", "last_name" ]); |
|
| 12 | 12 | } |
| 13 | 13 | } |
| 14 | 14 | \ No newline at end of file |
@@ -8,6 +8,6 @@ |
||
| 8 | 8 | { |
| 9 | 9 | public function __construct() |
| 10 | 10 | { |
| 11 | - parent::__construct("address", [], 'address_id'); |
|
| 11 | + parent::__construct("address", [ ], 'address_id'); |
|
| 12 | 12 | } |
| 13 | 13 | } |
| 14 | 14 | \ No newline at end of file |
@@ -23,10 +23,10 @@ |
||
| 23 | 23 | |
| 24 | 24 | print "update user"; |
| 25 | 25 | |
| 26 | -$name = ["Robson", "Kaue", "Gustavo", "João"]; |
|
| 26 | +$name = [ "Robson", "Kaue", "Gustavo", "João" ]; |
|
| 27 | 27 | |
| 28 | 28 | $user = (new User())->findById(100); |
| 29 | -$user->first_name = $name[rand(0, 3)]; |
|
| 29 | +$user->first_name = $name[ rand(0, 3) ]; |
|
| 30 | 30 | $user->save(); |
| 31 | 31 | |
| 32 | 32 | var_dump($user); |
@@ -23,9 +23,9 @@ discard block |
||
| 23 | 23 | protected function update(array $data, string $terms, string $params): ?int |
| 24 | 24 | { |
| 25 | 25 | try { |
| 26 | - $dateSet = []; |
|
| 26 | + $dateSet = [ ]; |
|
| 27 | 27 | foreach ($data as $bind => $value) { |
| 28 | - $dateSet[] = "{$bind} = :{$bind}"; |
|
| 28 | + $dateSet[ ] = "{$bind} = :{$bind}"; |
|
| 29 | 29 | } |
| 30 | 30 | $dateSet = implode(", ", $dateSet); |
| 31 | 31 | parse_str($params, $params); |
@@ -59,9 +59,9 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | private function filter(array $data): ?array |
| 61 | 61 | { |
| 62 | - $filter = []; |
|
| 62 | + $filter = [ ]; |
|
| 63 | 63 | foreach ($data as $key => $value) { |
| 64 | - $filter[$key] = (is_null($value) ? null : filter_var($value, FILTER_DEFAULT)); |
|
| 64 | + $filter[ $key ] = (is_null($value) ? null : filter_var($value, FILTER_DEFAULT)); |
|
| 65 | 65 | } |
| 66 | 66 | return $filter; |
| 67 | 67 | } |
@@ -155,9 +155,9 @@ discard block |
||
| 155 | 155 | |
| 156 | 156 | protected function required(): bool |
| 157 | 157 | { |
| 158 | - $data = (array)$this->data(); |
|
| 158 | + $data = (array) $this->data(); |
|
| 159 | 159 | foreach ($this->required as $field) { |
| 160 | - if (empty($data[$field])) { |
|
| 160 | + if (empty($data[ $field ])) { |
|
| 161 | 161 | return false; |
| 162 | 162 | } |
| 163 | 163 | } |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | protected function safe(): ?array |
| 168 | 168 | { |
| 169 | - $safe = (array)$this->data; |
|
| 170 | - foreach ([$this->primary, "updated_at", "created_at"] as $unset) { |
|
| 171 | - unset($safe[$unset]); |
|
| 169 | + $safe = (array) $this->data; |
|
| 170 | + foreach ([ $this->primary, "updated_at", "created_at" ] as $unset) { |
|
| 171 | + unset($safe[ $unset ]); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | return $safe; |