diff --git a/Authenticator/Attempt.php b/Authenticator/Attempt.php
index 5094205..03d7d8e 100755
--- a/Authenticator/Attempt.php
+++ b/Authenticator/Attempt.php
@@ -38,7 +38,7 @@ private function checkUserValide()
private function getUserData()
{
- $model = "\Model\\".$this->table['value'];
+ $model = "\Model\\" . $this->table['value'];
if ($this->optionalValue['value']) {
return $model::select()->where($this->identifier['key'], '=', $this->identifier['value'])->where($this->optionalValue['key'], '=', $this->optionalValue['value'])->get();
}
@@ -81,7 +81,7 @@ private function setup()
* remove white spaces from inputs & add slashes
*
* @return void
- */
+ */
private function secure()
{
foreach ($this->data as $key => $value) {
diff --git a/Box/FileGenerator.php b/Box/FileGenerator.php
index 457f84e..9c3ad58 100755
--- a/Box/FileGenerator.php
+++ b/Box/FileGenerator.php
@@ -35,7 +35,7 @@ public function __construct(string $command, string $argument, string $flag = nu
public function create()
{
- if (!file_put_contents($this->fileInfo->getFileDir().DIRECTORY_SEPARATOR.$this->fileInfo->getFileName().'.php', $this->template)) {
+ if (!file_put_contents($this->fileInfo->getFileDir() . DIRECTORY_SEPARATOR . $this->fileInfo->getFileName() . '.php', $this->template)) {
echo "can't create file";
exit();
}
@@ -45,7 +45,7 @@ public function create()
private function getTemplate()
{
- $templateGenerator = 'Box\TemplateGenerators\\'.$this->commandShortcuts[strtolower($this->command)];
+ $templateGenerator = 'Box\TemplateGenerators\\' . $this->commandShortcuts[strtolower($this->command)];
return $this->generateTemplate(new $templateGenerator($this->fileInfo->getFileDir(), $this->fileInfo->getFileName(), $this->flag));
}
diff --git a/Box/FileLocationResolver.php b/Box/FileLocationResolver.php
index 6489009..7cc4dc6 100755
--- a/Box/FileLocationResolver.php
+++ b/Box/FileLocationResolver.php
@@ -19,7 +19,7 @@ private function resolveDir(string $mainDir, string $dir)
return $mainDir;
}
- return $mainDir.'/'.$this->fileInfo['dirname'];
+ return $mainDir . '/' . $this->fileInfo['dirname'];
}
public function getFileName()
diff --git a/Box/TemplateGenerators/TemplateGenerator.php b/Box/TemplateGenerators/TemplateGenerator.php
index 4a61ea2..9eb4625 100755
--- a/Box/TemplateGenerators/TemplateGenerator.php
+++ b/Box/TemplateGenerators/TemplateGenerator.php
@@ -26,6 +26,6 @@ private function adapter()
{
$dir = explode('/', $this->directory);
$dir = array_slice($dir, 2, count($dir));
- $this->directory = empty($dir) ? implode('\\', $dir) : '\\'.implode('\\', $dir);
+ $this->directory = empty($dir) ? implode('\\', $dir) : '\\' . implode('\\', $dir);
}
}
diff --git a/Cookie/Cookie.php b/Cookie/Cookie.php
index f09d09d..af66ca2 100755
--- a/Cookie/Cookie.php
+++ b/Cookie/Cookie.php
@@ -1,4 +1,5 @@
$value) {
- setcookie($key, $value, time()-1);
+ setcookie($key, $value, time() - 1);
}
}
diff --git a/Kernel/Compiler/MiddlewareCompiler.php b/Kernel/Compiler/MiddlewareCompiler.php
index bbc288e..28e6b17 100755
--- a/Kernel/Compiler/MiddlewareCompiler.php
+++ b/Kernel/Compiler/MiddlewareCompiler.php
@@ -17,7 +17,7 @@ public function __construct(array $middlewares)
*/
public function execute(): void
{
- $middlewareProvider = require rootDir().getAliase('MiddlewaresProviders');
+ $middlewareProvider = require rootDir() . getAliase('MiddlewaresProviders');
foreach ($this->middlewares as $middleware) {
if (!array_key_exists($middleware, $middlewareProvider)) {
diff --git a/Kernel/Compiler/RouteCompiler.php b/Kernel/Compiler/RouteCompiler.php
index 21297d1..d2b9f4e 100755
--- a/Kernel/Compiler/RouteCompiler.php
+++ b/Kernel/Compiler/RouteCompiler.php
@@ -14,8 +14,8 @@ public function __construct(RouteInterface $route)
{
$this->route = $route;
$this->arguments = [
- container()->Request,
- container()->Response,
+ container()->Request,
+ container()->Response,
];
}
@@ -87,7 +87,7 @@ private function explodeController(RouteInterface $route): array
{
$parameters = explode('@', $route->getAction());
return [
- 'controller' => '\Controller\\'.$parameters[0],
+ 'controller' => '\Controller\\' . $parameters[0],
'method' => $parameters[1],
];
}
diff --git a/Kernel/Kernel.php b/Kernel/Kernel.php
index e2efddf..c64e7f6 100755
--- a/Kernel/Kernel.php
+++ b/Kernel/Kernel.php
@@ -14,7 +14,7 @@ public function prepare(): void
// load all service providers.
container()->build('Services\ServicesLoader');
// load routes
- container()->Router->call(rootDir().'App/Routes.php');
+ container()->Router->call(rootDir() . 'App/Routes.php');
}
/**
diff --git a/Model/Model.php b/Model/Model.php
index 3a59ee8..33a1b72 100755
--- a/Model/Model.php
+++ b/Model/Model.php
@@ -23,7 +23,7 @@ public function __construct()
}
}
- public static function getPDO(): \PDO
+ public static function getPDO(): PDO
{
$self = new static();
return $self->pdo;
diff --git a/Request/RequestMethodResolver.php b/Request/RequestMethodResolver.php
index bed7e1b..7978974 100755
--- a/Request/RequestMethodResolver.php
+++ b/Request/RequestMethodResolver.php
@@ -35,7 +35,7 @@ private function resolveMethodFromInputs(): string
private function getMethodFromRequest(): string
{
if (!in_array($this->request->body->_method, $this->allowedMethods)) {
- throw new \Exception($this->request->body->_method." Type of method is not supported", 1);
+ throw new \Exception($this->request->body->_method . " Type of method is not supported", 1);
}
return $this->request->body->_method;
diff --git a/Request/RequestMethodResolverInterface.php b/Request/RequestMethodResolverInterface.php
index b251375..ad14e61 100755
--- a/Request/RequestMethodResolverInterface.php
+++ b/Request/RequestMethodResolverInterface.php
@@ -1,4 +1,5 @@
method = $method;
- $this->routeUrl = $prefix.$routeUrl;
+ $this->routeUrl = $prefix . $routeUrl;
$this->action = $action;
$this->middlewares = new MiddlewaresCollection([]);
$this->lateMiddlewares = new MiddlewaresCollection([]);
diff --git a/Router/Router.php b/Router/Router.php
index 32b151f..f4abae1 100755
--- a/Router/Router.php
+++ b/Router/Router.php
@@ -41,7 +41,7 @@ public function call(string $routesFile): Router
return $this;
}
- throw new \Exception('This Page ('.url(currentUrl()).') Does Not Exist', 404);
+ throw new \Exception('This Page (' . url(currentUrl()) . ') Does Not Exist', 404);
}
/**
diff --git a/Router/UrlMatcher.php b/Router/UrlMatcher.php
index 25e87b0..97efe29 100755
--- a/Router/UrlMatcher.php
+++ b/Router/UrlMatcher.php
@@ -41,7 +41,7 @@ public function matchURL(): bool
private function matchUrlWithRoute(): bool
{
- for ($i=0; $i < count($this->url); $i++) {
+ for ($i = 0; $i < count($this->url); $i++) {
if (($this->url[$i] !== $this->route[$i]) && !$this->isVariable($this->url[$i], $this->route[$i])) {
return false;
}
diff --git a/Services/Helpers/helpers.php b/Services/Helpers/helpers.php
index eee87b7..d87741b 100755
--- a/Services/Helpers/helpers.php
+++ b/Services/Helpers/helpers.php
@@ -13,20 +13,20 @@ function view(string $view, array $data = [])
// return full valide url (inside application)
function url(string $url)
{
- $host = 'http'.(($_SERVER['SERVER_PORT'] == 443) ? 's://' : '://').$_SERVER['HTTP_HOST'].'/';
+ $host = 'http' . (($_SERVER['SERVER_PORT'] == 443) ? 's://' : '://') . $_SERVER['HTTP_HOST'] . '/';
- return $host.$url;
+ return $host . $url;
}
// redirect to a specific url (inside application);
function route(string $url)
{
- $host = 'http'.(($_SERVER['SERVER_PORT'] == 443) ? 's://' : '://').$_SERVER['HTTP_HOST'].'/';
- header('Location: '.$host.$url);
+ $host = 'http' . (($_SERVER['SERVER_PORT'] == 443) ? 's://' : '://') . $_SERVER['HTTP_HOST'] . '/';
+ header('Location: ' . $host . $url);
}
// reidrect to an external url
function redirect(string $url)
{
- header('Location: '.$url);
+ header('Location: ' . $url);
}
function setSession(string $key, string $value)
@@ -71,7 +71,7 @@ function destroyAllCookies()
function setLanguage(string $language): void
{
- setNewCookie('_language', $language, time()+3600*24*364);
+ setNewCookie('_language', $language, time() + 3600 * 24 * 364);
}
function getLanguage(): string
@@ -92,7 +92,7 @@ function csrf_field()
$token = uniqid(random_int(0, 1000));
}
setSession('_token', $token);
- echo "";
+ echo "";
}
function csrf_token()
@@ -124,7 +124,7 @@ function getAliase(string $aliase)
function rootDir()
{
- return $_SERVER['DOCUMENT_ROOT'].'/../';
+ return $_SERVER['DOCUMENT_ROOT'] . '/../';
}
function previousUrl()
diff --git a/Services/LanguagesResolver.php b/Services/LanguagesResolver.php
index bcfea1b..935187d 100755
--- a/Services/LanguagesResolver.php
+++ b/Services/LanguagesResolver.php
@@ -17,8 +17,8 @@ public static function resolve(string $path): array
private static function savePath(string $path): void
{
- $fullDir = rootDir().'resources/languages/'.$path.'.php';
-
+ $fullDir = rootDir() . 'resources/languages/' . $path . '.php';
+
if (!file_exists($fullDir)) {
throw new \Exception("Language file you are looking for don't exist: $path", 89);
}
diff --git a/Services/ServicesLoader.php b/Services/ServicesLoader.php
index 455634e..5d16a02 100755
--- a/Services/ServicesLoader.php
+++ b/Services/ServicesLoader.php
@@ -14,7 +14,7 @@ public function __construct()
private function loadApp()
{
- require rootDir().getAliase('App');
+ require rootDir() . getAliase('App');
}
private function loadServices()
diff --git a/Session/Session.php b/Session/Session.php
index babd94c..2601850 100755
--- a/Session/Session.php
+++ b/Session/Session.php
@@ -1,4 +1,5 @@
resolveValidator($validator);
+ $validator = "Validator\Validators\\" . $this->resolveValidator($validator);
return new $validator(...$arguments);
}
diff --git a/Validator/Validators/Length.php b/Validator/Validators/Length.php
index b127469..262f380 100755
--- a/Validator/Validators/Length.php
+++ b/Validator/Validators/Length.php
@@ -17,16 +17,16 @@ public function __construct(string $input, int $min, int $max, string $errorMsg)
$this->max = $max;
$this->errorMsg = $errorMsg;
}
-
+
public function check(): bool
{
if (!$this->maxLength($this->max) or !$this->minLength($this->min)) {
return false;
}
-
+
return true;
}
-
+
private function maxLength(int $max): bool
{
return (strlen($this->input) > $max) ? false : true;
diff --git a/Validator/Validators/Validatable.php b/Validator/Validators/Validatable.php
index ddf5ffb..78c8cb8 100755
--- a/Validator/Validators/Validatable.php
+++ b/Validator/Validators/Validatable.php
@@ -5,9 +5,9 @@
abstract class Validatable
{
protected $errorMsg;
-
+
abstract public function check(): bool;
-
+
public function getErrorMessage(): ?string
{
return $this->errorMsg;