Passed
Push — main ( 7f34fc...ff3d68 )
by Roberto
12:26
created
src/Exceptions/FieldException.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@
 block discarded – undo
7 7
 
8 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();
14 14
     parent::__construct($message, $code, $previous);
15
-  }
15
+    }
16 16
 }
17 17
\ No newline at end of file
Please login to merge, or discard this 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 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     /**
26 26
      * The reverse OneToMany and OneToOne relationships of the model.
27 27
      * @var array
28
-    */
28
+     */
29 29
 
30 30
     private array $reverseForeignKeys;
31 31
 
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
      * Update the data in the database using prepared queries.
494 494
      *
495 495
      * @return bool
496
-    */
496
+     */
497 497
     private function update()
498 498
     {
499 499
         $db = Application::getDb();
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 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();
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 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
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/Helpers/Functions.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -3,21 +3,21 @@
 block discarded – undo
3 3
 
4 4
 class Functions{
5 5
 static function getDeclarationLine(\ReflectionProperty $prop){
6
-  $declaringClass = $prop->getDeclaringClass();
7
-  $propname = $prop->getName();
8
-  $classFile      = new \SplFileObject($declaringClass->getFileName());
9
-  foreach ($classFile as $line => $content) {
10
-      if (preg_match(
11
-          '/
6
+    $declaringClass = $prop->getDeclaringClass();
7
+    $propname = $prop->getName();
8
+    $classFile      = new \SplFileObject($declaringClass->getFileName());
9
+    foreach ($classFile as $line => $content) {
10
+        if (preg_match(
11
+            '/
12 12
               (private|protected|public|var|static) # match visibility or var
13 13
               \s                             # followed 1 whitespace
14 14
               \$'.$propname.'                          # followed by the var name $bar
15 15
           /x',
16
-          $content)
17
-      ) {
18
-          return $line + 1;
19
-      }
20
-  }
21
-  return 1;
16
+            $content)
17
+        ) {
18
+            return $line + 1;
19
+        }
20
+    }
21
+    return 1;
22 22
 }
23 23
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace Lepton\Helpers;
3 3
 
4
-class Functions{
5
-static function getDeclarationLine(\ReflectionProperty $prop){
4
+class Functions {
5
+static function getDeclarationLine(\ReflectionProperty $prop) {
6 6
   $declaringClass = $prop->getDeclaringClass();
7 7
   $propname = $prop->getName();
8 8
   $classFile      = new \SplFileObject($declaringClass->getFileName());
Please login to merge, or discard this patch.
src/Routing/Match/MatchRoute.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,6 +5,6 @@
 block discarded – undo
5 5
 
6 6
 class MatchRoute extends BaseMatch
7 7
 {
8
-  public function __construct(public $controller, public $method, public $parameters){}
8
+    public function __construct(public $controller, public $method, public $parameters){}
9 9
 
10 10
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,6 +5,6 @@
 block discarded – undo
5 5
 
6 6
 class MatchRoute extends BaseMatch
7 7
 {
8
-  public function __construct(public $controller, public $method, public $parameters){}
8
+  public function __construct(public $controller, public $method, public $parameters) {}
9 9
 
10 10
 }
Please login to merge, or discard this patch.
src/Routing/Match/MatchFile.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,9 +5,9 @@
 block discarded – undo
5 5
 
6 6
 class MatchFile extends BaseMatch
7 7
 {
8
-  public function __construct(public $filePath, public $contentType)
9
-  {
8
+    public function __construct(public $filePath, public $contentType)
9
+    {
10 10
 
11
-  }
11
+    }
12 12
 
13 13
 }
Please login to merge, or discard this patch.
src/Routing/UrlResolver.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 class UrlResolver
12 12
 {
13 13
 
14
-    public function __construct(private $pattern){}
14
+    public function __construct(private $pattern) {}
15 15
 
16 16
     public function patternPrepare($pattern)
17 17
     {
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         $is_match = preg_match(sprintf("/^%s$/", $pattern), $_SERVER['REQUEST_URI'], $parameters);
52 52
 
53 53
         // keep only string keys
54
-        $parameters = array_filter($parameters, function ($k) {
54
+        $parameters = array_filter($parameters, function($k) {
55 55
             return is_string($k);
56 56
         }, ARRAY_FILTER_USE_KEY);
57 57
         return $is_match;
Please login to merge, or discard this patch.
src/Core/Mailer.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
         $this->mailer->addReplyTo($config->replyTo, $config->replyToName);
29 29
     }
30 30
 
31
-    public function send($to, $subject, $body, $attachments=array())
31
+    public function send($to, $subject, $body, $attachments = array())
32 32
     {
33 33
         $this->mailer->addAddress($to);
34 34
         $this->mailer->Subject = $subject;
Please login to merge, or discard this patch.
src/Core/Handler/AbstractHandler.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
     protected $middlewares = array();
16 16
 
17 17
     public function __construct($request){
18
-      $this->request = $request;
18
+        $this->request = $request;
19 19
     }
20 20
 
21 21
     public function addMiddlewares($middlewares) {
@@ -24,12 +24,12 @@  discard block
 block discarded – undo
24 24
 
25 25
 
26 26
     public function getResponse() : HttpResponse{
27
-      $matcher = $this->resolveRequest();
28
-      return $this->handle($matcher);
27
+        $matcher = $this->resolveRequest();
28
+        return $this->handle($matcher);
29 29
 
30 30
     }
31 31
 
32 32
 
33 33
 
34
-  }
34
+    }
35 35
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
     protected Request $request;
15 15
     protected $middlewares = array();
16 16
 
17
-    public function __construct($request){
17
+    public function __construct($request) {
18 18
       $this->request = $request;
19 19
     }
20 20
 
Please login to merge, or discard this patch.
src/Core/Application.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@
 block discarded – undo
61 61
      * Returns the appropriate handler for the pending request
62 62
      *
63 63
      * @return AbstractHandler $handler
64
-    */
64
+     */
65 65
     public static function getHandler(): AbstractHandler
66 66
     {
67 67
         $regex = '/\.(?:'.implode('|', static::$_config->static_files_extensions).')$/';
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,13 +29,13 @@  discard block
 block discarded – undo
29 29
      */
30 30
     public static function run()
31 31
     {
32
-        if(! static::$_config) {
32
+        if (!static::$_config) {
33 33
             throw new \Exception("No config loaded!");
34 34
         }
35 35
 
36 36
         session_start();
37 37
 
38
-        if(static::$_dbconfig->use_db) {
38
+        if (static::$_dbconfig->use_db) {
39 39
             static::$_db = new Database(
40 40
                 static::$_dbconfig->host,
41 41
                 static::$_dbconfig->user,
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
         $response = $handler->getResponse();
50 50
         $response->send();
51 51
 
52
-        if(static::$_dbconfig->use_db) {
52
+        if (static::$_dbconfig->use_db) {
53 53
             static::$_db->close();
54 54
         }
55 55
 
@@ -82,33 +82,33 @@  discard block
 block discarded – undo
82 82
 
83 83
     public static function loadConfig(\stdClass $config)
84 84
     {
85
-        if(property_exists($config, "app")) {
85
+        if (property_exists($config, "app")) {
86 86
             static::$_config = $config->app;
87 87
         } else {
88 88
             throw new \Exception("No app configuration!");
89 89
         }
90 90
 
91
-        if(property_exists($config, "routes")) {
91
+        if (property_exists($config, "routes")) {
92 92
             static::$routes = $config->routes;
93 93
         } else {
94 94
             throw new \Exception("No routes configuration!");
95 95
         }
96 96
 
97 97
 
98
-        if(property_exists($config, "database")) {
98
+        if (property_exists($config, "database")) {
99 99
             static::$_dbconfig = $config->database;
100 100
         } else {
101 101
             throw new \Exception("No database configuration!");
102 102
         }
103 103
 
104 104
 
105
-        if(property_exists($config, "auth")) {
105
+        if (property_exists($config, "auth")) {
106 106
             static::$_auth = $config->auth;
107 107
         } else {
108 108
             throw new \Exception("No authentication configuration!");
109 109
         }
110 110
 
111
-        if(property_exists($config, "email")) {
111
+        if (property_exists($config, "email")) {
112 112
             static::$_email = $config->email;
113 113
         } else {
114 114
             throw new \Exception("No email configuration!");
Please login to merge, or discard this patch.