Passed
Push — main ( bae336...1e821c )
by Roberto
01:48
created
src/Exceptions/InvalidFieldTypeException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,4 +3,4 @@
 block discarded – undo
3 3
 
4 4
 use Exception;
5 5
 
6
-class InvalidFieldTypeException extends Exception{}
7 6
\ No newline at end of file
7
+class InvalidFieldTypeException extends Exception {}
8 8
\ No newline at end of file
Please login to merge, or discard this patch.
src/Exceptions/FieldException.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,9 +5,9 @@
 block discarded – undo
5 5
 use Throwable;
6 6
 use Lepton\Helpers\Functions;
7 7
 
8
-class FieldException extends Exception{
8
+class FieldException extends Exception {
9 9
 
10
-  public function __construct(\ReflectionProperty $prop, $message = "", $code = 0, ?\Throwable $previous = null){
10
+  public function __construct(\ReflectionProperty $prop, $message = "", $code = 0, ?\Throwable $previous = null) {
11 11
 
12 12
     $this->line = Functions::getDeclarationLine($prop);
13 13
     $this->file = $prop->getDeclaringClass()->getFileName();
Please login to merge, or discard this patch.
src/Boson/Model.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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();
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
             if (is_subclass_of(($attribute->getName()), DataTypes\Field::class)) {
242 242
                 // A field should have only one field type
243 243
                 if (is_null($fieldType)) {
244
-                    $fieldType =  $attribute;
244
+                    $fieldType = $attribute;
245 245
                 } else {
246 246
                     throw new Exceptions\MultipleFieldAttributeException($prop);
247 247
                 }
@@ -264,8 +264,8 @@  discard block
 block discarded – undo
264 264
     private function checkFieldsAreProtected()
265 265
     {
266 266
         $properties = (new \ReflectionClass(get_class($this)))->getProperties(
267
-            \ReflectionProperty::IS_PUBLIC |
268
-            \ReflectionProperty::IS_READONLY |
267
+            \ReflectionProperty::IS_PUBLIC|
268
+            \ReflectionProperty::IS_READONLY|
269 269
             \ReflectionProperty::IS_STATIC
270 270
         );
271 271
         foreach ($properties as $prop) {
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
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
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 
575 575
     public static function get(...$filters): Model|bool
576 576
     {
577
-        if ((count($filters) == 1) && array_key_first($filters)  == 0) {
577
+        if ((count($filters) == 1) && array_key_first($filters) == 0) {
578 578
             $filters = array((new static())->pkName => $filters[0]);
579 579
         }
580 580
 
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 
585 585
         $result = $querySet->do();
586 586
         if ($result->count() == 0) {
587
-            return false;//throw new \Exception("No result found");
587
+            return false; //throw new \Exception("No result found");
588 588
         } elseif ($result->count() > 1) {
589 589
             throw new \Exception("Only one result allowed when using get, multiple obtained");
590 590
         } else {
Please login to merge, or discard this patch.
src/Boson/DataTypes/Field.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
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.",
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
   }
35 35
 
36 36
 
37
-  protected function check(){
37
+  protected function check() {
38 38
     return true;
39 39
   }
40 40
 
Please login to merge, or discard this patch.
src/Boson/DataTypes/DateField.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,12 +2,12 @@
 block discarded – undo
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
     return true;
12 12
   }
13 13
 
Please login to merge, or discard this patch.
src/Boson/DataTypes/PrimaryKey.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -2,13 +2,13 @@
 block discarded – undo
2 2
 namespace Lepton\Boson\DataTypes;
3 3
 
4 4
 #[\Attribute]
5
-class PrimaryKey extends Field{
6
-  public function __construct(private int $max_length = 32, mixed ...$options){
5
+class PrimaryKey extends Field {
6
+  public function __construct(private int $max_length = 32, mixed ...$options) {
7 7
     parent::__construct(...$options);
8 8
   }
9 9
 
10
-  public function validate($value){
11
-    if(is_null($value) && (!$this->null)) return false;
10
+  public function validate($value) {
11
+    if (is_null($value) && (!$this->null)) return false;
12 12
     return true;
13 13
   }
14 14
 }
15 15
\ No newline at end of file
Please login to merge, or discard this patch.
src/Boson/DataTypes/NumberField.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -2,13 +2,13 @@
 block discarded – undo
2 2
 namespace Lepton\Boson\DataTypes;
3 3
 
4 4
 #[\Attribute]
5
-class NumberField extends Field{
6
-  public function __construct(private int $max_length = 32, mixed ...$options){
5
+class NumberField extends Field {
6
+  public function __construct(private int $max_length = 32, mixed ...$options) {
7 7
     parent::__construct(...$options);
8 8
   }
9 9
 
10
-  public function validate($value){
11
-    if(is_null($value) && (!$this->null)) return false;
10
+  public function validate($value) {
11
+    if (is_null($value) && (!$this->null)) return false;
12 12
     return true;
13 13
   }
14 14
 }
15 15
\ No newline at end of file
Please login to merge, or discard this patch.
src/Boson/DataTypes/TextField.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -2,21 +2,21 @@
 block discarded – undo
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
   private $max_length;
9 9
   private $nullable;
10 10
 
11
-  public function __construct($max_length = 128, $nullable = false ){
11
+  public function __construct($max_length = 128, $nullable = false) {
12 12
     $this->max_length = $max_length;
13 13
     $this->nullable = $nullable;
14 14
   }
15 15
 
16
-  public function validate($value){
16
+  public function validate($value) {
17 17
     return true;
18
-    if(is_null($value) && (!$this->nullable)) return false;
19
-    if(strlen($value) > $this->max_length) return false;
18
+    if (is_null($value) && (!$this->nullable)) return false;
19
+    if (strlen($value) > $this->max_length) return false;
20 20
     return true;
21 21
   }
22 22
 }
23 23
\ No newline at end of file
Please login to merge, or discard this patch.
src/Boson/DataTypes/CharField.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@
 block discarded – undo
12 12
 
13 13
     public function validate($value)
14 14
     {
15
-        if(is_null($value) && (!$this->null)) return false;
16
-        if(strlen($value) > $this->max_length) return false;
15
+        if (is_null($value) && (!$this->null)) return false;
16
+        if (strlen($value) > $this->max_length) return false;
17 17
         return true;
18 18
     }
19 19
 }
Please login to merge, or discard this patch.