@@ -19,11 +19,11 @@ |
||
19 | 19 | { |
20 | 20 | if ($this->exception instanceof AuthException) { |
21 | 21 | die('User must be logged in'); |
22 | - }else if ($this->exception instanceof NotCallableException) { |
|
22 | + } else if ($this->exception instanceof NotCallableException) { |
|
23 | 23 | die('Method not found'); |
24 | 24 | } if ($this->exception instanceof MethodNotAllowedException) { |
25 | 25 | die('Not allowed'); |
26 | - }else { |
|
26 | + } else { |
|
27 | 27 | echo $this->exception->getMessage(); |
28 | 28 | } |
29 | 29 | } |
@@ -54,7 +54,7 @@ |
||
54 | 54 | * |
55 | 55 | * @param string $view |
56 | 56 | */ |
57 | - public function render($view = null , $params = null) |
|
57 | + public function render($view = null, $params = null) |
|
58 | 58 | { |
59 | 59 | $params = ($params) ? $params : $this->params; |
60 | 60 | $view = $view ?: $this->template; |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | use Carbon\Carbon; |
5 | 5 | use Core\Lib\Controller; |
6 | 6 | |
7 | -class Utils extends Controller{ |
|
7 | +class Utils extends Controller { |
|
8 | 8 | |
9 | 9 | private static $instance; |
10 | 10 | public $debug; |
@@ -65,15 +65,15 @@ discard block |
||
65 | 65 | * @return string |
66 | 66 | */ |
67 | 67 | public static function textLimit($string, $size) { |
68 | - $string = (strlen($string) <= $size) ? $string : substr($string, 0, $size) . '...'; |
|
68 | + $string = (strlen($string) <= $size) ? $string : substr($string, 0, $size).'...'; |
|
69 | 69 | return $string; |
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
73 | 73 | * @param $uri |
74 | 74 | */ |
75 | - public function active($uri){ |
|
76 | - echo (str_replace('/','.',substr($_SERVER['REQUEST_URI'], 1)) == $uri)? "class='active'" : ""; |
|
75 | + public function active($uri) { |
|
76 | + echo (str_replace('/', '.', substr($_SERVER['REQUEST_URI'], 1)) == $uri) ? "class='active'" : ""; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | static function value($key = null) { |
83 | 83 | if (isset($key) && $key !== null) { |
84 | - return (isset($_REQUEST[$key])) ? ' value=' . $_REQUEST[$key] . '' : false; |
|
84 | + return (isset($_REQUEST[$key])) ? ' value='.$_REQUEST[$key].'' : false; |
|
85 | 85 | } |
86 | 86 | return true; |
87 | 87 | } |
@@ -151,18 +151,18 @@ discard block |
||
151 | 151 | return $res; |
152 | 152 | } |
153 | 153 | |
154 | - public static function setDebug($exceptionCode){ |
|
154 | + public static function setDebug($exceptionCode) { |
|
155 | 155 | $exception = null; |
156 | - switch ($exceptionCode){ |
|
156 | + switch ($exceptionCode) { |
|
157 | 157 | case 23000 : $exception = "Erro ao inserir os dados!"; break; |
158 | 158 | } |
159 | 159 | $print = "<div class='debug'>"; |
160 | 160 | $print .= $exception; |
161 | 161 | $print .= "</div>"; |
162 | - self::getInstance()->debug = $print; |
|
162 | + self::getInstance()->debug = $print; |
|
163 | 163 | } |
164 | 164 | |
165 | - public static function getDebug(){ |
|
165 | + public static function getDebug() { |
|
166 | 166 | echo self::getInstance()->debug; |
167 | 167 | } |
168 | 168 | |
@@ -172,15 +172,15 @@ discard block |
||
172 | 172 | * @return string |
173 | 173 | */ |
174 | 174 | public static function generateToken($length = 20) { |
175 | - if(function_exists('openssl_random_pseudo_bytes')) { |
|
175 | + if (function_exists('openssl_random_pseudo_bytes')) { |
|
176 | 176 | $token = base64_encode(openssl_random_pseudo_bytes($length, $strong)); |
177 | - if($strong == TRUE) |
|
177 | + if ($strong == TRUE) |
|
178 | 178 | return strtr(substr($token, 0, $length), '+/=', '-_,'); |
179 | 179 | } |
180 | 180 | |
181 | 181 | $characters = '0123456789'; |
182 | 182 | $characters .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
183 | - $charactersLength = strlen($characters)-1; |
|
183 | + $charactersLength = strlen($characters) - 1; |
|
184 | 184 | $token = ''; |
185 | 185 | |
186 | 186 | for ($i = 0; $i < $length; $i++) { |
@@ -5,14 +5,14 @@ discard block |
||
5 | 5 | |
6 | 6 | class Paginate extends Controller |
7 | 7 | { |
8 | - public $perPage, $currentPage, $total , $maxPage , $items , $skip; |
|
8 | + public $perPage, $currentPage, $total, $maxPage, $items, $skip; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Paginate constructor. |
12 | 12 | */ |
13 | 13 | public function __construct() { |
14 | 14 | parent::__construct(); |
15 | - $this->setCurrentPage((isset($_GET['page']))?$_GET['page']:1); |
|
15 | + $this->setCurrentPage((isset($_GET['page'])) ? $_GET['page'] : 1); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | /** |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function setItems($items) |
78 | 78 | { |
79 | - $count = ceil($items->count()/$this->getPerPage()); |
|
80 | - $maxPages = (!empty($this->getMaxPages()) && $count >$this->getMaxPages())?$this->getMaxPages():$count; |
|
79 | + $count = ceil($items->count() / $this->getPerPage()); |
|
80 | + $maxPages = (!empty($this->getMaxPages()) && $count > $this->getMaxPages()) ? $this->getMaxPages() : $count; |
|
81 | 81 | $this->setTotal($maxPages); |
82 | - $this->setSkip(($this->getCurrentPage()*$this->getPerPage())-$this->getPerPage()); |
|
83 | - $this->items = $items->skip($this->getSkip())->limit($this->getPerPage())->get(); |
|
82 | + $this->setSkip(($this->getCurrentPage() * $this->getPerPage()) - $this->getPerPage()); |
|
83 | + $this->items = $items->skip($this->getSkip())->limit($this->getPerPage())->get(); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -116,12 +116,12 @@ discard block |
||
116 | 116 | } |
117 | 117 | |
118 | 118 | |
119 | - public function paginate(){ |
|
120 | - if($this->getTotal() != 1) { |
|
119 | + public function paginate() { |
|
120 | + if ($this->getTotal() != 1) { |
|
121 | 121 | echo /** @lang text */ '<ul class="pagination">'; |
122 | - if($this->getCurrentPage() > 1){ |
|
123 | - echo /** @lang text */ '<li><a href="?page='.($this->getCurrentPage()-1).'" aria-label="Previous"><span aria-hidden="true">Anterior</span></a></li>'; |
|
124 | - }else{ |
|
122 | + if ($this->getCurrentPage() > 1) { |
|
123 | + echo /** @lang text */ '<li><a href="?page='.($this->getCurrentPage() - 1).'" aria-label="Previous"><span aria-hidden="true">Anterior</span></a></li>'; |
|
124 | + } else { |
|
125 | 125 | echo /** @lang text */ '<li class="disabled"><a aria-label="Previous"><span aria-hidden="true">Anterior</span></a></li>'; |
126 | 126 | } |
127 | 127 | |
@@ -129,11 +129,11 @@ discard block |
||
129 | 129 | |
130 | 130 | $active = ($this->getCurrentPage() == $i) ? 'class="active"' : ''; |
131 | 131 | |
132 | - echo '<li ' . $active . '><a href="?page=' . $i . '">' . $i . '</a></li>'; |
|
132 | + echo '<li '.$active.'><a href="?page='.$i.'">'.$i.'</a></li>'; |
|
133 | 133 | } |
134 | - if($this->getCurrentPage() < $this->getTotal()){ |
|
135 | - echo /** @lang text */ '<li><a href="?page='.($this->getCurrentPage()+1).'" aria-label="Next"><span aria-hidden="true">Próxima</span></a></li>'; |
|
136 | - }else{ |
|
134 | + if ($this->getCurrentPage() < $this->getTotal()) { |
|
135 | + echo /** @lang text */ '<li><a href="?page='.($this->getCurrentPage() + 1).'" aria-label="Next"><span aria-hidden="true">Próxima</span></a></li>'; |
|
136 | + } else { |
|
137 | 137 | echo /** @lang text */ '<li class="disabled"><a aria-label="Next"><span aria-hidden="true">Próxima</span></a></li>'; |
138 | 138 | } |
139 | 139 | echo '</ul>'; |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | { |
16 | 16 | |
17 | 17 | public $capsuleDb = array(); |
18 | - public $cache , $session , $di; |
|
18 | + public $cache, $session, $di; |
|
19 | 19 | private static $instance; |
20 | 20 | |
21 | 21 | public function __construct() |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | $di_builder->useAutowiring(true); |
25 | 25 | $this->di = $di_builder->build(); |
26 | 26 | $this->session = new Session(); |
27 | - try{ |
|
27 | + try { |
|
28 | 28 | $this->capsuleDb = new Capsule(); |
29 | 29 | $this->capsuleDb->addConnection(Config::get('database.providers.pdo')); |
30 | 30 | $this->capsuleDb->setEventDispatcher(new Dispatcher(new Container)); |
31 | 31 | $this->capsuleDb->bootEloquent(); |
32 | 32 | $this->capsuleDb->setAsGlobal(); |
33 | 33 | $this->db = $this->capsuleDb->getConnection(); |
34 | - }catch (\PDOException $exc){ |
|
34 | + } catch (\PDOException $exc) { |
|
35 | 35 | die("Database ".Config::get('database.providers.pdo.database')." not found"); |
36 | 36 | } |
37 | 37 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | public function redirect($url) |
74 | 74 | { |
75 | 75 | $url = str_replace(".", DS, $url); |
76 | - return header('location: /' . $url); |
|
76 | + return header('location: /'.$url); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -107,10 +107,10 @@ discard block |
||
107 | 107 | $controllerParams[$paramName] = $paramValue; |
108 | 108 | } |
109 | 109 | } |
110 | - $controllerFullName = "\\App\\Controllers\\" . $routerParams["_controller"]; |
|
111 | - try{ |
|
110 | + $controllerFullName = "\\App\\Controllers\\".$routerParams["_controller"]; |
|
111 | + try { |
|
112 | 112 | return $this->di->call($controllerFullName."::".$routerParams["_method"], $controllerParams); |
113 | - }catch (Exception $e){ |
|
113 | + } catch (Exception $e) { |
|
114 | 114 | new ExceptionHandler($e); |
115 | 115 | } |
116 | 116 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | protected $blade; |
17 | 17 | |
18 | - public $framework , $request , $response , $params; |
|
18 | + public $framework, $request, $response, $params; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Controller constructor. |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | public function __construct() { |
24 | 24 | parent::__construct(); |
25 | 25 | |
26 | - $this->framework= (object) Config::get('framework'); |
|
26 | + $this->framework = (object) Config::get('framework'); |
|
27 | 27 | $this->request = (new Request); |
28 | 28 | $this->response = (new Response); |
29 | 29 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function view($view, $params = null) { |
47 | 47 | $render = View::getInstance(); |
48 | - $render->render($view,$params); |
|
48 | + $render->render($view, $params); |
|
49 | 49 | |
50 | 50 | return $render; |
51 | 51 | } |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | * @return bool |
71 | 71 | */ |
72 | 72 | public function hasFile($key) { |
73 | - if($this->request->capture()->hasFile($key)){ |
|
73 | + if ($this->request->capture()->hasFile($key)) { |
|
74 | 74 | return $this->request->capture()->file($key); |
75 | - }else{ |
|
75 | + } else { |
|
76 | 76 | return $this->request->capture()->hasFile($key); |
77 | 77 | } |
78 | 78 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return bool |
86 | 86 | */ |
87 | - public function isMethod($method){ |
|
87 | + public function isMethod($method) { |
|
88 | 88 | return $this->request->capture()->isMethod($method); |
89 | 89 | } |
90 | 90 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @return string |
95 | 95 | */ |
96 | - public function method(){ |
|
96 | + public function method() { |
|
97 | 97 | return $this->request->capture()->method(); |
98 | 98 | } |
99 | 99 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @return string|array |
107 | 107 | */ |
108 | 108 | public function input($key = null, $default = null) { |
109 | - return $this->request->capture()->input($key , $default); |
|
109 | + return $this->request->capture()->input($key, $default); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @param mixed $default |
138 | 138 | * @return mixed |
139 | 139 | */ |
140 | - public function json($key = null, $default = null){ |
|
140 | + public function json($key = null, $default = null) { |
|
141 | 141 | return $this->request->json($key, $default); |
142 | 142 | } |
143 | 143 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return bool |
148 | 148 | */ |
149 | - public function ajax(){ |
|
149 | + public function ajax() { |
|
150 | 150 | return $this->request->json(); |
151 | 151 | } |
152 | 152 |
@@ -59,8 +59,8 @@ |
||
59 | 59 | */ |
60 | 60 | public function make() { |
61 | 61 | $view = include $this->config_path.'views.php'; |
62 | - $app = include $this->config_path.'app.php'; |
|
63 | - $database = include $this->config_path.'database.php'; |
|
62 | + $app = include $this->config_path.'app.php'; |
|
63 | + $database = include $this->config_path.'database.php'; |
|
64 | 64 | $mail = include $this->config_path.'mail.php'; |
65 | 65 | $this->config_array['views'] = $view; |
66 | 66 | $this->config_array['app'] = $app; |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | } |
105 | 105 | |
106 | 106 | list($controller, $method) = explode("::", $controller); |
107 | - $prefixedPath = $this->prefix . $path; |
|
107 | + $prefixedPath = $this->prefix.$path; |
|
108 | 108 | |
109 | 109 | $configsParams = array_merge(array( |
110 | 110 | "_path" => $path, |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | $route = new Route($prefixedPath, $configsParams); |
120 | 120 | $route->setMethods($httpMethod); |
121 | - $this->routeColletion->add(implode("", $httpMethod) . $prefixedPath, $route); |
|
121 | + $this->routeColletion->add(implode("", $httpMethod).$prefixedPath, $route); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | '_method' => '_404', |
143 | 143 | '_route' => 'GETPOSTPUTPATCHDELETEPATCH/' |
144 | 144 | ]; |
145 | - } catch (Exception $e){ |
|
145 | + } catch (Exception $e) { |
|
146 | 146 | new ExceptionHandler($e); |
147 | 147 | } |
148 | 148 | return $parameters; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | { |
152 | 152 | static $included = false; |
153 | 153 | if (!$included) { |
154 | - require ROOT_APP . "routes.php"; |
|
154 | + require ROOT_APP."routes.php"; |
|
155 | 155 | $included = true; |
156 | 156 | } |
157 | 157 | } |
@@ -17,15 +17,15 @@ |
||
17 | 17 | * |
18 | 18 | * @return mixed |
19 | 19 | */ |
20 | - public static function __callStatic($function, $arguments){ |
|
20 | + public static function __callStatic($function, $arguments) { |
|
21 | 21 | return call_user_func_array(array(static::instance(), $function), $arguments); |
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
25 | 25 | * @return Capsule |
26 | 26 | */ |
27 | - public static function instance(){ |
|
28 | - if(!self::$instance){ |
|
27 | + public static function instance() { |
|
28 | + if (!self::$instance) { |
|
29 | 29 | self::$instance = (new Capsule); |
30 | 30 | } |
31 | 31 | return self::$instance; |