@@ -44,15 +44,15 @@ discard block |
||
| 44 | 44 | $session_hash = bin2hex(random_bytes(32)); |
| 45 | 45 | $_SESSION['user_id'] = $user->getPk(); |
| 46 | 46 | $_SESSION['session_hash'] = $session_hash; |
| 47 | - if($this->config->login_use_unique_hash) { |
|
| 47 | + if ($this->config->login_use_unique_hash) { |
|
| 48 | 48 | $hashField = $this->config->hash_field; |
| 49 | 49 | $user->$hashField = $session_hash; |
| 50 | 50 | $user->save(); |
| 51 | 51 | } |
| 52 | - if(isset($this->config->access_field)){ |
|
| 52 | + if (isset($this->config->access_field)) { |
|
| 53 | 53 | $accessField = $this->config->access_field; |
| 54 | 54 | date_default_timezone_set('Europe/Rome'); |
| 55 | - $user->$accessField = date('Y-m-d H:i:s', time());; |
|
| 55 | + $user->$accessField = date('Y-m-d H:i:s', time()); ; |
|
| 56 | 56 | $user->save(); |
| 57 | 57 | } |
| 58 | 58 | return true; |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | // Hash the password |
| 104 | - if (! $password) { |
|
| 104 | + if (!$password) { |
|
| 105 | 105 | $password = $this->randomPassword(length: $password_length); |
| 106 | 106 | } |
| 107 | 107 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | { |
| 135 | 135 | if ($this->isLoggedIn()) { |
| 136 | 136 | if (isset($_SESSION['user_id'])) { |
| 137 | - if(isset($this->config->hash_field)) { |
|
| 137 | + if (isset($this->config->hash_field)) { |
|
| 138 | 138 | $user = $this->getUserById($_SESSION['user_id']); |
| 139 | 139 | $hashField = $this->config->hash_field; |
| 140 | 140 | $user->$hashField = ""; |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | $user->$hashField = $session_hash; |
| 50 | 50 | $user->save(); |
| 51 | 51 | } |
| 52 | - if(isset($this->config->access_field)){ |
|
| 52 | + if(isset($this->config->access_field)) { |
|
| 53 | 53 | $accessField = $this->config->access_field; |
| 54 | 54 | date_default_timezone_set('Europe/Rome'); |
| 55 | 55 | $user->$accessField = date('Y-m-d H:i:s', time());; |
@@ -72,7 +72,8 @@ discard block |
||
| 72 | 72 | $user = $this->getUserById($user_id); |
| 73 | 73 | |
| 74 | 74 | //$hashField = $this->config->hash_field; |
| 75 | - if (!$user) {// || $user->$hashField !== $_SESSION['session_hash']) { |
|
| 75 | + if (!$user) { |
|
| 76 | +// || $user->$hashField !== $_SESSION['session_hash']) { |
|
| 76 | 77 | return false; |
| 77 | 78 | } |
| 78 | 79 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | protected array $custom_filters; |
| 15 | 15 | public string $baseLink; |
| 16 | 16 | |
| 17 | - public function url($string){ |
|
| 17 | + public function url($string) { |
|
| 18 | 18 | return Application::getDir()."/".$string; |
| 19 | 19 | } |
| 20 | 20 | |
@@ -23,16 +23,16 @@ discard block |
||
| 23 | 23 | Liquid::set('INCLUDE_SUFFIX', 'html'); |
| 24 | 24 | Liquid::set('INCLUDE_PREFIX', ''); |
| 25 | 25 | $path = "app/Views"; |
| 26 | - $template = new Template($path); |
|
| 26 | + $template = new Template($path); |
|
| 27 | 27 | $template->registerFilter(new SiteFilter()); |
| 28 | 28 | |
| 29 | - if(isset($this->custom_filters)){ |
|
| 30 | - foreach($this->custom_filters as $filter){ |
|
| 29 | + if (isset($this->custom_filters)) { |
|
| 30 | + foreach ($this->custom_filters as $filter) { |
|
| 31 | 31 | $template->registerFilter(new $filter()); |
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | $template->parseFile($view); |
| 35 | - $parameters = array_map(function ($x) { |
|
| 35 | + $parameters = array_map(function($x) { |
|
| 36 | 36 | if ($x instanceof QuerySet) { |
| 37 | 37 | return $x->do(); |
| 38 | 38 | } else { |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | if (!isset(static::$tableName)) { |
| 102 | 102 | $class = new \ReflectionClass(get_class($this)); |
| 103 | 103 | try { |
| 104 | - $className = explode("\\", $class->getName()); |
|
| 104 | + $className = explode("\\", $class->getName()); |
|
| 105 | 105 | static::$tableName = strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', end($className))); |
| 106 | 106 | } catch (\Exception $e) { |
| 107 | 107 | throw new Exceptions\TableNameNotSetException($class); |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | $this->pkName = $maybeField->getName(); |
| 140 | 140 | |
| 141 | 141 | // If column name is not set, use field name |
| 142 | - if($field->db_column() == "") { |
|
| 142 | + if ($field->db_column() == "") { |
|
| 143 | 143 | $field->set_db_column($maybeField->getName()); |
| 144 | 144 | } |
| 145 | 145 | } |
@@ -150,12 +150,12 @@ discard block |
||
| 150 | 150 | elseif ($fieldType->getName() == DataTypes\ForeignKey::class) { |
| 151 | 151 | $this->foreignKeys[$maybeField->getName()] = $field; |
| 152 | 152 | // If column name is not set, build it as {fieldName}_{parentPrimaryKeyName} |
| 153 | - if($field->db_column() == "") { |
|
| 153 | + if ($field->db_column() == "") { |
|
| 154 | 154 | $props = (new \ReflectionClass($field->parent))->getProperties(\ReflectionProperty::IS_PROTECTED); |
| 155 | 155 | $parentPkName = ""; |
| 156 | - foreach($props as $prop) { |
|
| 156 | + foreach ($props as $prop) { |
|
| 157 | 157 | $attributes = $prop->getAttributes(DataTypes\PrimaryKey::class); |
| 158 | - if(count($attributes)) { |
|
| 158 | + if (count($attributes)) { |
|
| 159 | 159 | $parentPkName = $prop->getName(); |
| 160 | 160 | } |
| 161 | 161 | } |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | $this->fields[$maybeField->getName()] = $field; |
| 177 | 177 | |
| 178 | 178 | // If column name is not set, use field name |
| 179 | - if($field->db_column() == "") { |
|
| 179 | + if ($field->db_column() == "") { |
|
| 180 | 180 | $field->set_db_column($maybeField->getName()); |
| 181 | 181 | } |
| 182 | 182 | $this->db_columns[$maybeField->getName()] = $field->db_column(); |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | if (is_subclass_of(($attribute->getName()), DataTypes\Field::class)) { |
| 243 | 243 | // A field should have only one field type |
| 244 | 244 | if (is_null($fieldType)) { |
| 245 | - $fieldType = $attribute; |
|
| 245 | + $fieldType = $attribute; |
|
| 246 | 246 | } else { |
| 247 | 247 | throw new Exceptions\MultipleFieldAttributeException($prop); |
| 248 | 248 | } |
@@ -265,8 +265,8 @@ discard block |
||
| 265 | 265 | private function checkFieldsAreProtected() |
| 266 | 266 | { |
| 267 | 267 | $properties = (new \ReflectionClass(get_class($this)))->getProperties( |
| 268 | - \ReflectionProperty::IS_PUBLIC | |
|
| 269 | - \ReflectionProperty::IS_READONLY | |
|
| 268 | + \ReflectionProperty::IS_PUBLIC| |
|
| 269 | + \ReflectionProperty::IS_READONLY| |
|
| 270 | 270 | \ReflectionProperty::IS_STATIC |
| 271 | 271 | ); |
| 272 | 272 | foreach ($properties as $prop) { |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | return $parent; |
| 302 | 302 | } elseif ($property == $this->pkName) { |
| 303 | 303 | return $this->getPk(); |
| 304 | - } elseif($this->isReverseForeignKey($property)) { |
|
| 304 | + } elseif ($this->isReverseForeignKey($property)) { |
|
| 305 | 305 | $child = $this->reverseForeignKeys[$property]->child; |
| 306 | 306 | $arguments = [ |
| 307 | 307 | $this->reverseForeignKeys[$property]->foreignKey => $this |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | $this->$property = $value; |
| 338 | 338 | } |
| 339 | 339 | } elseif (array_key_exists($property, $this->foreignKeys)) { |
| 340 | - if(is_null($value)){ |
|
| 340 | + if (is_null($value)) { |
|
| 341 | 341 | $this->$property = $value; |
| 342 | 342 | $this->editedFields[] = $property; |
| 343 | 343 | $this->editedFields = array_unique($this->editedFields); |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | if (array_key_exists($field, $this->fields)) { |
| 596 | 596 | return $this->$field; |
| 597 | 597 | } elseif (array_key_exists($field, $this->foreignKeys)) { |
| 598 | - if(is_null($this->$field)) return NULL; |
|
| 598 | + if (is_null($this->$field)) return NULL; |
|
| 599 | 599 | return ($this->$field)->getPk(); |
| 600 | 600 | } |
| 601 | 601 | } |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | */ |
| 613 | 613 | public static function get(...$filters): Model|bool |
| 614 | 614 | { |
| 615 | - if ((count($filters) == 1) && array_key_first($filters) == 0) { |
|
| 615 | + if ((count($filters) == 1) && array_key_first($filters) == 0) { |
|
| 616 | 616 | $filters = array((new static())->pkName => $filters[0]); |
| 617 | 617 | } |
| 618 | 618 | |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | $this->$property = $value; |
| 338 | 338 | } |
| 339 | 339 | } elseif (array_key_exists($property, $this->foreignKeys)) { |
| 340 | - if(is_null($value)){ |
|
| 340 | + if(is_null($value)) { |
|
| 341 | 341 | $this->$property = $value; |
| 342 | 342 | $this->editedFields[] = $property; |
| 343 | 343 | $this->editedFields = array_unique($this->editedFields); |
@@ -595,7 +595,9 @@ discard block |
||
| 595 | 595 | if (array_key_exists($field, $this->fields)) { |
| 596 | 596 | return $this->$field; |
| 597 | 597 | } elseif (array_key_exists($field, $this->foreignKeys)) { |
| 598 | - if(is_null($this->$field)) return NULL; |
|
| 598 | + if(is_null($this->$field)) { |
|
| 599 | + return NULL; |
|
| 600 | + } |
|
| 599 | 601 | return ($this->$field)->getPk(); |
| 600 | 602 | } |
| 601 | 603 | } |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | |
| 13 | 13 | public function validate($value) |
| 14 | 14 | { |
| 15 | - if(strlen($value) > $this->max_length) return false; |
|
| 15 | + if (strlen($value) > $this->max_length) return false; |
|
| 16 | 16 | return parent::validate($value); |
| 17 | 17 | } |
| 18 | 18 | } |
@@ -12,7 +12,9 @@ |
||
| 12 | 12 | |
| 13 | 13 | public function validate($value) |
| 14 | 14 | { |
| 15 | - if(strlen($value) > $this->max_length) return false; |
|
| 15 | + if(strlen($value) > $this->max_length) { |
|
| 16 | + return false; |
|
| 17 | + } |
|
| 16 | 18 | return parent::validate($value); |
| 17 | 19 | } |
| 18 | 20 | } |
@@ -4,59 +4,59 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Field{ |
| 6 | 6 | |
| 7 | - protected array $default_error_messages = array( |
|
| 7 | + protected array $default_error_messages = array( |
|
| 8 | 8 | "invalid_choice" => "Value %value is not a valid choice.", |
| 9 | 9 | "null" => "This field cannot be null.", |
| 10 | 10 | "blank" => "This field cannot be blank.", |
| 11 | 11 | "unique" => "A %model_name with this %field_label already exists.", |
| 12 | 12 | "unique_for" => "Field %field_label must be unique for fields with same %unique_for." |
| 13 | - ); |
|
| 14 | - |
|
| 15 | - protected array $validation_errors = array(); |
|
| 16 | - |
|
| 17 | - public function __construct( |
|
| 18 | - protected bool $null = false, |
|
| 19 | - protected bool $blank = true, |
|
| 20 | - protected array $choices = array(), |
|
| 21 | - protected string $db_column = "", |
|
| 22 | - protected mixed $default = "", |
|
| 23 | - protected bool $editable = true, |
|
| 24 | - protected array $error_messages = array(), |
|
| 25 | - protected string $help_text = "", |
|
| 26 | - protected bool $primary_key = false, |
|
| 27 | - protected bool $unique = false, |
|
| 28 | - protected string $verbose_name = "", |
|
| 29 | - protected array $validators = array() |
|
| 13 | + ); |
|
| 14 | + |
|
| 15 | + protected array $validation_errors = array(); |
|
| 16 | + |
|
| 17 | + public function __construct( |
|
| 18 | + protected bool $null = false, |
|
| 19 | + protected bool $blank = true, |
|
| 20 | + protected array $choices = array(), |
|
| 21 | + protected string $db_column = "", |
|
| 22 | + protected mixed $default = "", |
|
| 23 | + protected bool $editable = true, |
|
| 24 | + protected array $error_messages = array(), |
|
| 25 | + protected string $help_text = "", |
|
| 26 | + protected bool $primary_key = false, |
|
| 27 | + protected bool $unique = false, |
|
| 28 | + protected string $verbose_name = "", |
|
| 29 | + protected array $validators = array() |
|
| 30 | 30 | ) |
| 31 | - { |
|
| 31 | + { |
|
| 32 | 32 | return; |
| 33 | - } |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | 35 | |
| 36 | - protected function validate($value){ |
|
| 36 | + protected function validate($value){ |
|
| 37 | 37 | if (is_null($value) && (!$this->null)) return false; |
| 38 | 38 | if (empty($value) && (!$this->blank)) return false; |
| 39 | 39 | if (!empty($this->choices) && !in_array($value, $this->choices)) return false; |
| 40 | 40 | if (!empty($this->validators)) return $this->validate_with_validators($value); |
| 41 | 41 | |
| 42 | 42 | return true; |
| 43 | - } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | 45 | |
| 46 | - private function validate_with_validators($value){ |
|
| 46 | + private function validate_with_validators($value){ |
|
| 47 | 47 | foreach($this->validators as $validator){ |
| 48 | - if (!$validator($value)) return false; |
|
| 48 | + if (!$validator($value)) return false; |
|
| 49 | 49 | } |
| 50 | 50 | return true; |
| 51 | - } |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | 53 | |
| 54 | 54 | |
| 55 | - public function db_column(): string{ |
|
| 55 | + public function db_column(): string{ |
|
| 56 | 56 | return $this->db_column; |
| 57 | - } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - public function set_db_column(string $column_name): void{ |
|
| 59 | + public function set_db_column(string $column_name): void{ |
|
| 60 | 60 | $this->db_column = $column_name; |
| 61 | - } |
|
| 61 | + } |
|
| 62 | 62 | } |
| 63 | 63 | \ No newline at end of file |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | namespace Lepton\Boson\DataTypes; |
| 3 | 3 | |
| 4 | 4 | |
| 5 | -class Field{ |
|
| 5 | +class Field { |
|
| 6 | 6 | |
| 7 | 7 | protected array $default_error_messages = array( |
| 8 | 8 | "invalid_choice" => "Value %value is not a valid choice.", |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | |
| 36 | - protected function validate($value){ |
|
| 36 | + protected function validate($value) { |
|
| 37 | 37 | if (is_null($value) && (!$this->null)) return false; |
| 38 | 38 | if (empty($value) && (!$this->blank)) return false; |
| 39 | 39 | if (!empty($this->choices) && !in_array($value, $this->choices)) return false; |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | |
| 46 | - private function validate_with_validators($value){ |
|
| 47 | - foreach($this->validators as $validator){ |
|
| 46 | + private function validate_with_validators($value) { |
|
| 47 | + foreach ($this->validators as $validator) { |
|
| 48 | 48 | if (!$validator($value)) return false; |
| 49 | 49 | } |
| 50 | 50 | return true; |
@@ -34,10 +34,18 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | protected function validate($value){ |
| 37 | - if (is_null($value) && (!$this->null)) return false; |
|
| 38 | - if (empty($value) && (!$this->blank)) return false; |
|
| 39 | - if (!empty($this->choices) && !in_array($value, $this->choices)) return false; |
|
| 40 | - if (!empty($this->validators)) return $this->validate_with_validators($value); |
|
| 37 | + if (is_null($value) && (!$this->null)) { |
|
| 38 | + return false; |
|
| 39 | + } |
|
| 40 | + if (empty($value) && (!$this->blank)) { |
|
| 41 | + return false; |
|
| 42 | + } |
|
| 43 | + if (!empty($this->choices) && !in_array($value, $this->choices)) { |
|
| 44 | + return false; |
|
| 45 | + } |
|
| 46 | + if (!empty($this->validators)) { |
|
| 47 | + return $this->validate_with_validators($value); |
|
| 48 | + } |
|
| 41 | 49 | |
| 42 | 50 | return true; |
| 43 | 51 | } |
@@ -45,7 +53,9 @@ discard block |
||
| 45 | 53 | |
| 46 | 54 | private function validate_with_validators($value){ |
| 47 | 55 | foreach($this->validators as $validator){ |
| 48 | - if (!$validator($value)) return false; |
|
| 56 | + if (!$validator($value)) { |
|
| 57 | + return false; |
|
| 58 | + } |
|
| 49 | 59 | } |
| 50 | 60 | return true; |
| 51 | 61 | } |
@@ -6,13 +6,13 @@ |
||
| 6 | 6 | |
| 7 | 7 | |
| 8 | 8 | |
| 9 | - public function __construct(private $max_length = 128, ...$options ){ |
|
| 10 | - parent::__construct(...$options); |
|
| 9 | + public function __construct(private $max_length = 128, ...$options ){ |
|
| 10 | + parent::__construct(...$options); |
|
| 11 | 11 | |
| 12 | - } |
|
| 12 | + } |
|
| 13 | 13 | |
| 14 | - public function validate($value){ |
|
| 14 | + public function validate($value){ |
|
| 15 | 15 | if(strlen($value) > $this->max_length) return false; |
| 16 | 16 | return parent::validate($value); |
| 17 | - } |
|
| 17 | + } |
|
| 18 | 18 | } |
| 19 | 19 | \ No newline at end of file |
@@ -2,17 +2,17 @@ |
||
| 2 | 2 | namespace Lepton\Boson\DataTypes; |
| 3 | 3 | |
| 4 | 4 | #[\Attribute] |
| 5 | -class TextField extends Field{ |
|
| 5 | +class TextField extends Field { |
|
| 6 | 6 | |
| 7 | 7 | |
| 8 | 8 | |
| 9 | - public function __construct(private $max_length = 128, ...$options ){ |
|
| 9 | + public function __construct(private $max_length = 128, ...$options) { |
|
| 10 | 10 | parent::__construct(...$options); |
| 11 | 11 | |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - public function validate($value){ |
|
| 15 | - if(strlen($value) > $this->max_length) return false; |
|
| 14 | + public function validate($value) { |
|
| 15 | + if (strlen($value) > $this->max_length) return false; |
|
| 16 | 16 | return parent::validate($value); |
| 17 | 17 | } |
| 18 | 18 | } |
| 19 | 19 | \ No newline at end of file |
@@ -12,7 +12,9 @@ |
||
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | public function validate($value){ |
| 15 | - if(strlen($value) > $this->max_length) return false; |
|
| 15 | + if(strlen($value) > $this->max_length) { |
|
| 16 | + return false; |
|
| 17 | + } |
|
| 16 | 18 | return parent::validate($value); |
| 17 | 19 | } |
| 18 | 20 | } |
| 19 | 21 | \ No newline at end of file |
@@ -14,7 +14,9 @@ |
||
| 14 | 14 | |
| 15 | 15 | public function validate($value) |
| 16 | 16 | { |
| 17 | - if (!is_a($value, $this->child)) return false; |
|
| 17 | + if (!is_a($value, $this->child)) { |
|
| 18 | + return false; |
|
| 19 | + } |
|
| 18 | 20 | return parent::validate($value); |
| 19 | 21 | } |
| 20 | 22 | } |
@@ -3,13 +3,13 @@ |
||
| 3 | 3 | |
| 4 | 4 | #[\Attribute] |
| 5 | 5 | class DateField extends Field{ |
| 6 | - public function __construct(...$args){ |
|
| 6 | + public function __construct(...$args){ |
|
| 7 | 7 | parent::__construct(...$args); |
| 8 | - } |
|
| 8 | + } |
|
| 9 | 9 | |
| 10 | - public function validate($value){ |
|
| 10 | + public function validate($value){ |
|
| 11 | 11 | if (!preg_match("/\d{4}-\d{2}-\d{2}/", $value)) return false; |
| 12 | 12 | return parent::validate($value); |
| 13 | - } |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | 15 | } |
| 16 | 16 | \ No newline at end of file |
@@ -2,12 +2,12 @@ |
||
| 2 | 2 | namespace Lepton\Boson\DataTypes; |
| 3 | 3 | |
| 4 | 4 | #[\Attribute] |
| 5 | -class DateField extends Field{ |
|
| 6 | - public function __construct(...$args){ |
|
| 5 | +class DateField extends Field { |
|
| 6 | + public function __construct(...$args) { |
|
| 7 | 7 | parent::__construct(...$args); |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | - public function validate($value){ |
|
| 10 | + public function validate($value) { |
|
| 11 | 11 | if (!preg_match("/\d{4}-\d{2}-\d{2}/", $value)) return false; |
| 12 | 12 | return parent::validate($value); |
| 13 | 13 | } |
@@ -8,7 +8,9 @@ |
||
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | public function validate($value){ |
| 11 | - if (!preg_match("/\d{4}-\d{2}-\d{2}/", $value)) return false; |
|
| 11 | + if (!preg_match("/\d{4}-\d{2}-\d{2}/", $value)) { |
|
| 12 | + return false; |
|
| 13 | + } |
|
| 12 | 14 | return parent::validate($value); |
| 13 | 15 | } |
| 14 | 16 | |
@@ -3,12 +3,12 @@ |
||
| 3 | 3 | |
| 4 | 4 | #[\Attribute] |
| 5 | 5 | class NumberField extends Field{ |
| 6 | - public function __construct(mixed ...$options){ |
|
| 6 | + public function __construct(mixed ...$options){ |
|
| 7 | 7 | parent::__construct(...$options); |
| 8 | - } |
|
| 8 | + } |
|
| 9 | 9 | |
| 10 | - public function validate($value){ |
|
| 10 | + public function validate($value){ |
|
| 11 | 11 | if(!is_numeric($value)) return false; |
| 12 | 12 | return parent::validate($value); |
| 13 | - } |
|
| 13 | + } |
|
| 14 | 14 | } |
| 15 | 15 | \ No newline at end of file |
@@ -2,13 +2,13 @@ |
||
| 2 | 2 | namespace Lepton\Boson\DataTypes; |
| 3 | 3 | |
| 4 | 4 | #[\Attribute] |
| 5 | -class NumberField extends Field{ |
|
| 6 | - public function __construct(mixed ...$options){ |
|
| 5 | +class NumberField extends Field { |
|
| 6 | + public function __construct(mixed ...$options) { |
|
| 7 | 7 | parent::__construct(...$options); |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | - public function validate($value){ |
|
| 11 | - if(!is_numeric($value)) return false; |
|
| 10 | + public function validate($value) { |
|
| 11 | + if (!is_numeric($value)) return false; |
|
| 12 | 12 | return parent::validate($value); |
| 13 | 13 | } |
| 14 | 14 | } |
| 15 | 15 | \ No newline at end of file |
@@ -8,7 +8,9 @@ |
||
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | public function validate($value){ |
| 11 | - if(!is_numeric($value)) return false; |
|
| 11 | + if(!is_numeric($value)) { |
|
| 12 | + return false; |
|
| 13 | + } |
|
| 12 | 14 | return parent::validate($value); |
| 13 | 15 | } |
| 14 | 16 | } |
| 15 | 17 | \ No newline at end of file |