| @@ -104,9 +104,9 @@ | ||
| 104 | 104 | $protocol = $request->getUri()->getScheme(); | 
| 105 | 105 | $baseHost = $request->getUri()->getHost(); | 
| 106 | 106 | $path = $request->getUri()->getPath(); | 
| 107 | -        $pathArr = explode('/',$path); | |
| 108 | - unset($pathArr[count($pathArr)-1]); | |
| 109 | -        $path = implode('/',$pathArr); | |
| 107 | +        $pathArr = explode('/', $path); | |
| 108 | + unset($pathArr[count($pathArr) - 1]); | |
| 109 | +        $path = implode('/', $pathArr); | |
| 110 | 110 | $port = $request->getUri()->getPort() ? ':' . $request->getUri()->getPort() : ''; | 
| 111 | 111 | $baseUrl = $protocol . '://' . $baseHost . $port . $path; | 
| 112 | 112 | return $baseUrl; | 
| @@ -11,7 +11,7 @@ discard block | ||
| 11 | 11 | |
| 12 | 12 | abstract class _TranslateHandler | 
| 13 | 13 |  { | 
| 14 | - protected $container ; | |
| 14 | + protected $container; | |
| 15 | 15 | protected $local; | 
| 16 | 16 | |
| 17 | 17 | function __construct($container) | 
| @@ -37,5 +37,5 @@ discard block | ||
| 37 | 37 | return $this->container; | 
| 38 | 38 | } | 
| 39 | 39 | |
| 40 | - abstract public function trans(string $key , array $replace); | |
| 40 | + abstract public function trans(string $key, array $replace); | |
| 41 | 41 | } | 
| 42 | 42 | \ No newline at end of file | 
| @@ -19,40 +19,40 @@ discard block | ||
| 19 | 19 | } | 
| 20 | 20 | |
| 21 | 21 | |
| 22 | - private function _loadkey(string $key , array $replace = []) | |
| 22 | + private function _loadkey(string $key, array $replace = []) | |
| 23 | 23 |      { | 
| 24 | -        list($namespace,$group) = explode('.',$key); | |
| 24 | +        list($namespace, $group) = explode('.', $key); | |
| 25 | 25 | $t_dir = $this->getTranslation_dirs(); | 
| 26 | 26 | |
| 27 | -        if(in_array($this->local,$t_dir)){ | |
| 27 | +        if (in_array($this->local, $t_dir)) { | |
| 28 | 28 | |
| 29 | - $translationBaseFolder = $this->settings['translation']['translations_path'].$this->local; | |
| 30 | - $translationBaseFile = $translationBaseFolder.'/'.$namespace.'.php'; | |
| 29 | + $translationBaseFolder = $this->settings['translation']['translations_path'] . $this->local; | |
| 30 | + $translationBaseFile = $translationBaseFolder . '/' . $namespace . '.php'; | |
| 31 | 31 | |
| 32 | -            if(file_exists($translationBaseFolder)){ | |
| 33 | - $lang= include_once ($translationBaseFile); | |
| 34 | -            }else{ | |
| 32 | +            if (file_exists($translationBaseFolder)) { | |
| 33 | + $lang = include_once ($translationBaseFile); | |
| 34 | +            }else { | |
| 35 | 35 | |
| 36 | 36 | } | 
| 37 | -        }else{ | |
| 37 | +        }else { | |
| 38 | 38 | |
| 39 | 39 | } | 
| 40 | 40 | |
| 41 | 41 | |
| 42 | -        if(count($replace) > 0){ | |
| 43 | -            foreach($replace as $key=>$replace_item){ | |
| 44 | -                if(strpos($lang[$group],'%') != 0){ | |
| 45 | - str_replace($key,$replace_item,$lang[$group]); | |
| 42 | +        if (count($replace) > 0) { | |
| 43 | +            foreach ($replace as $key=>$replace_item) { | |
| 44 | +                if (strpos($lang[$group], '%') != 0) { | |
| 45 | + str_replace($key, $replace_item, $lang[$group]); | |
| 46 | 46 | } | 
| 47 | 47 | } | 
| 48 | -        }else{ | |
| 48 | +        }else { | |
| 49 | 49 | return $lang[$group]; | 
| 50 | 50 | } | 
| 51 | 51 | } | 
| 52 | 52 | |
| 53 | 53 | public function trans(string $key, array $replace = []) | 
| 54 | 54 |      { | 
| 55 | - return $this->_loadkey($key,$replace); | |
| 55 | + return $this->_loadkey($key, $replace); | |
| 56 | 56 | } | 
| 57 | 57 | |
| 58 | 58 | |
| @@ -64,7 +64,7 @@ discard block | ||
| 64 | 64 | |
| 65 | 65 | |
| 66 | 66 | |
| 67 | - return array_diff($dir,$ex_folders); | |
| 67 | + return array_diff($dir, $ex_folders); | |
| 68 | 68 | } | 
| 69 | 69 | |
| 70 | 70 | } | 
| 71 | 71 | \ No newline at end of file | 
| @@ -34,8 +34,8 @@ discard block | ||
| 34 | 34 | |
| 35 | 35 | public function resource($url, $controller, $args = []) | 
| 36 | 36 |      { | 
| 37 | - $url = rtrim($url,'/'); | |
| 38 | -        $this->app->group($url, function () use ($controller, $args) { | |
| 37 | + $url = rtrim($url, '/'); | |
| 38 | +        $this->app->group($url, function() use ($controller, $args) { | |
| 39 | 39 |              $this->get('', $controller . ':index')->add(self::middleware('index', $args)); | 
| 40 | 40 |              $this->get('/create', $controller . ':create')->add(self::middleware('create', $args)); | 
| 41 | 41 |              $this->get('/{id:[0-9]+}', $controller . ':show')->add(self::middleware('show', $args)); | 
| @@ -55,7 +55,7 @@ discard block | ||
| 55 | 55 | */ | 
| 56 | 56 | public static function middleware($middleWare = "group", $args) | 
| 57 | 57 |      { | 
| 58 | -        $routeResourceMiddleWare_default = function ($request, $response, $next) { | |
| 58 | +        $routeResourceMiddleWare_default = function($request, $response, $next) { | |
| 59 | 59 | return $next($request, $response); | 
| 60 | 60 | }; | 
| 61 | 61 | |
| @@ -24,14 +24,14 @@ | ||
| 24 | 24 | return isset($_SESSION['user']); | 
| 25 | 25 | } | 
| 26 | 26 | |
| 27 | - public function attempt(string $username, string $email,string $mobile,string $password) | |
| 27 | + public function attempt(string $username, string $email, string $mobile, string $password) | |
| 28 | 28 |      { | 
| 29 | - $user = UserDataAccess::getUserByEmail_OR_Mobile_OR_Username_one_r($username,$email,$mobile)->first(); | |
| 29 | + $user = UserDataAccess::getUserByEmail_OR_Mobile_OR_Username_one_r($username, $email, $mobile)->first(); | |
| 30 | 30 | |
| 31 | 31 |          if (!$user) { | 
| 32 | 32 | return false; | 
| 33 | 33 | } | 
| 34 | -        if (password_verify($password,$user->password)) { | |
| 34 | +        if (password_verify($password, $user->password)) { | |
| 35 | 35 | $_SESSION['user'] = $user->id; | 
| 36 | 36 | return true; | 
| 37 | 37 | } | 
| @@ -11,14 +11,14 @@ | ||
| 11 | 11 | |
| 12 | 12 | class Env | 
| 13 | 13 |  { | 
| 14 | - public function __invoke($filePath ,$key, $default = null) | |
| 14 | + public function __invoke($filePath, $key, $default = null) | |
| 15 | 15 |      { | 
| 16 | 16 | |
| 17 | 17 |          if (file_exists($filePath . '/.env')) { | 
| 18 | - $_dotenv = new Dotenv($filePath ); | |
| 18 | + $_dotenv = new Dotenv($filePath); | |
| 19 | 19 | $_dotenv->load(); | 
| 20 | 20 | unset($_dotenv); | 
| 21 | -        }else{ | |
| 21 | +        }else { | |
| 22 | 22 | |
| 23 | 23 |              die('enviroment file (`.env`) not found in project root  '); | 
| 24 | 24 | } | 
| @@ -8,14 +8,14 @@ discard block | ||
| 8 | 8 | |
| 9 | 9 | namespace Core\Helpers; | 
| 10 | 10 | |
| 11 | -class Hash{ | |
| 11 | +class Hash { | |
| 12 | 12 | /** | 
| 13 | 13 | * Receives a string password and hashes it. | 
| 14 | 14 | * | 
| 15 | 15 | * @param string $password | 
| 16 | 16 | * @return string $hash | 
| 17 | 17 | */ | 
| 18 | -    public static function hash($password){ | |
| 18 | +    public static function hash($password) { | |
| 19 | 19 | return password_hash($password, PASSWORD_DEFAULT); | 
| 20 | 20 | } | 
| 21 | 21 | |
| @@ -26,8 +26,8 @@ discard block | ||
| 26 | 26 | * @param string $hash | 
| 27 | 27 | * @return boolean If the hash was generated from the password | 
| 28 | 28 | */ | 
| 29 | -    public static function checkHash($string, $hash){ | |
| 30 | -        if( password_verify( $string, $hash ) ){ | |
| 29 | +    public static function checkHash($string, $hash) { | |
| 30 | +        if (password_verify($string, $hash)) { | |
| 31 | 31 | return true; | 
| 32 | 32 | } | 
| 33 | 33 | return false; | 
| @@ -16,7 +16,7 @@ discard block | ||
| 16 | 16 |              if (!headers_sent()) { | 
| 17 | 17 |                  header('Location: ' . $location); | 
| 18 | 18 | exit; | 
| 19 | -            } else { | |
| 19 | +            }else { | |
| 20 | 20 | echo '<script type="text/javascript">'; | 
| 21 | 21 | echo 'window.location.href="' . $location . '";'; | 
| 22 | 22 | echo '</script>'; | 
| @@ -33,7 +33,7 @@ discard block | ||
| 33 | 33 | exit; | 
| 34 | 34 | } | 
| 35 | 35 | |
| 36 | -    public static function getPrevious(){ | |
| 36 | +    public static function getPrevious() { | |
| 37 | 37 | return $_SERVER['HTTP_REFERER']; | 
| 38 | 38 | } | 
| 39 | 39 | public static function getRoot($exclude_path = '') | 
| @@ -22,11 +22,11 @@ | ||
| 22 | 22 | |
| 23 | 23 | public function render(ResponseInterface $response, $template, array $data = []) | 
| 24 | 24 |      { | 
| 25 | -        if ($this->layout){ | |
| 25 | +        if ($this->layout) { | |
| 26 | 26 | $viewOutput = $this->fetch($template, $data); | 
| 27 | 27 |              $layoutOutput = $this->fetch($this->layout, array('content' => $viewOutput)); | 
| 28 | 28 | $response->getBody()->write($layoutOutput); | 
| 29 | -        } else { | |
| 29 | +        }else { | |
| 30 | 30 | $output = parent::render($response, $template, $data); | 
| 31 | 31 | $response->getBody()->write($output); | 
| 32 | 32 | } |