@@ -5,9 +5,9 @@ |
||
| 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(); |
@@ -1,8 +1,8 @@ |
||
| 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()); |
@@ -5,6 +5,6 @@ |
||
| 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 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 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 |
||
| 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; |
@@ -28,7 +28,7 @@ |
||
| 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; |
@@ -14,7 +14,7 @@ |
||
| 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 | |
@@ -29,13 +29,13 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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!"); |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | parent::__construct(headers: ["Content-Type" => $contentType]); |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | - public function sendBody(){ |
|
| 17 | + public function sendBody() { |
|
| 18 | 18 | readfile($this->filePath); |
| 19 | 19 | } |
| 20 | 20 | |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | public $headers; |
| 10 | 10 | public $body; |
| 11 | 11 | |
| 12 | - public function __construct($url, $htmx = false, $parse = true, $code = 302, $redirect_after = null ) |
|
| 12 | + public function __construct($url, $htmx = false, $parse = true, $code = 302, $redirect_after = null) |
|
| 13 | 13 | { |
| 14 | 14 | if ($this->isLocalUrl($url) && $parse) { |
| 15 | 15 | $parsedUrl = Application::getDir()."/".$url; |
@@ -19,9 +19,9 @@ discard block |
||
| 19 | 19 | if ($htmx) { |
| 20 | 20 | $headers = ["HX-Redirect" => $parsedUrl]; |
| 21 | 21 | } else { |
| 22 | - $headers = [ "Location" => $parsedUrl ]; |
|
| 22 | + $headers = ["Location" => $parsedUrl]; |
|
| 23 | 23 | } |
| 24 | - if(isset($redirect_after)){ |
|
| 24 | + if (isset($redirect_after)) { |
|
| 25 | 25 | $_SESSION["redirect_url"] = $redirect_after; |
| 26 | 26 | |
| 27 | 27 | } |