@@ -1,15 +1,15 @@ discard block |
||
1 | 1 | <?php |
2 | -if(! function_exists("dd")) { |
|
2 | +if (!function_exists("dd")) { |
|
3 | 3 | /** |
4 | 4 | * Little helper called dump and die |
5 | 5 | * @param $val |
6 | 6 | */ |
7 | 7 | function dd($val) { |
8 | - var_dump($val);die; |
|
8 | + var_dump($val); die; |
|
9 | 9 | } |
10 | 10 | } |
11 | 11 | |
12 | -if(! function_exists("pathTo")) { |
|
12 | +if (!function_exists("pathTo")) { |
|
13 | 13 | /** |
14 | 14 | * Easy function to get the path to the project + if you want an directory in it. |
15 | 15 | * |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | } |
22 | 22 | } |
23 | 23 | |
24 | -if(! function_exists("view")) { |
|
24 | +if (!function_exists("view")) { |
|
25 | 25 | /** |
26 | 26 | * Get the evaluated view contents for the given view. |
27 | 27 | * |
@@ -29,14 +29,14 @@ discard block |
||
29 | 29 | * @param array $data Data to set values in template file |
30 | 30 | * @return \app\framework\Component\View\View|string |
31 | 31 | */ |
32 | - function view($view = null, $data = []) { |
|
33 | - $data['auth'] = new \app\framework\Component\Auth\Auth; |
|
32 | + function view($view = null, $data = [ ]) { |
|
33 | + $data[ 'auth' ] = new \app\framework\Component\Auth\Auth; |
|
34 | 34 | $View = new \app\framework\Component\View\View($view, $data); |
35 | 35 | return $View->render(); |
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | -if(! function_exists("app")) { |
|
39 | +if (!function_exists("app")) { |
|
40 | 40 | /** |
41 | 41 | * Used to easily call Methods from classes without manually set |
42 | 42 | * locally Instances of them. |
@@ -45,12 +45,12 @@ discard block |
||
45 | 45 | * @param array $param To declare what parameter shall be passed to the method |
46 | 46 | * @return mixed |
47 | 47 | */ |
48 | - function app($classMethod, $param = []) { |
|
49 | - return $GLOBALS["App"]->call($classMethod, $param); |
|
48 | + function app($classMethod, $param = [ ]) { |
|
49 | + return $GLOBALS[ "App" ]->call($classMethod, $param); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | -if(! function_exists("url")) { |
|
53 | +if (!function_exists("url")) { |
|
54 | 54 | /** |
55 | 55 | * Basically completes just the the url |
56 | 56 | * e.g. /test to yourexample.site/test |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | * @return string |
63 | 63 | */ |
64 | 64 | function url($path) { |
65 | - return $_SERVER['HTTP_HOST'].$path; |
|
65 | + return $_SERVER[ 'HTTP_HOST' ].$path; |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | -if(! function_exists("getStringBetween")) { |
|
69 | +if (!function_exists("getStringBetween")) { |
|
70 | 70 | /** |
71 | 71 | * This is a handy little function to strip out a string between |
72 | 72 | * two specified pieces of text. This could be used to parse |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @return bool|string |
79 | 79 | */ |
80 | 80 | function getStringBetween($string, $start, $end) { |
81 | - $string = ' ' . $string; |
|
81 | + $string = ' '.$string; |
|
82 | 82 | $ini = strpos($string, $start); |
83 | 83 | if ($ini == 0) return ''; |
84 | 84 | $ini += strlen($start); |
@@ -87,13 +87,13 @@ discard block |
||
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | -if(! function_exists("handle")) { |
|
91 | - function handle( $e) { |
|
90 | +if (!function_exists("handle")) { |
|
91 | + function handle($e) { |
|
92 | 92 | \app\framework\Component\Exception\Handler::getInstance()->handler($e); |
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | -if(! function_exists("arr")) { |
|
96 | +if (!function_exists("arr")) { |
|
97 | 97 | /** |
98 | 98 | * Create an ArrayObject from array |
99 | 99 | * @param array $arr |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | -if(! function_exists("encrypt")) { |
|
107 | +if (!function_exists("encrypt")) { |
|
108 | 108 | /** |
109 | 109 | * Encrypt the given value. |
110 | 110 | * |
@@ -118,11 +118,11 @@ discard block |
||
118 | 118 | \app\framework\Component\Config\Config::getInstance()->get("CrypKey") |
119 | 119 | ); |
120 | 120 | |
121 | - return $Encryptor->encrypt($value, $serialize ); |
|
121 | + return $Encryptor->encrypt($value, $serialize); |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
125 | -if(! function_exists("decrypt")) { |
|
125 | +if (!function_exists("decrypt")) { |
|
126 | 126 | /** |
127 | 127 | * Decrypt the given value. |
128 | 128 | * |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | \app\framework\Component\Config\Config::getInstance()->get("CrypKey") |
137 | 137 | ); |
138 | 138 | |
139 | - return $Encryptor->decrypt($value, $unserialize ); |
|
139 | + return $Encryptor->decrypt($value, $unserialize); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
143 | -if(! function_exists("version")) { |
|
143 | +if (!function_exists("version")) { |
|
144 | 144 | /** |
145 | 145 | * @return string version as written in config/app.php |
146 | 146 | */ |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
152 | -if(! function_exists("isDebug")) { |
|
152 | +if (!function_exists("isDebug")) { |
|
153 | 153 | function isDebug() { |
154 | 154 | return \app\framework\Component\Config\Config::getInstance()->get("debug", "app"); |
155 | 155 | } |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | // Get all of our request params |
298 | 298 | $params = $this->params(); |
299 | 299 | |
300 | - return isset($params[$key]) ? $params[$key] : $default; |
|
300 | + return isset($params[ $key ]) ? $params[ $key ] : $default; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | // Get all of our request params |
315 | 315 | $params = $this->params(); |
316 | 316 | |
317 | - return isset($params[$param]); |
|
317 | + return isset($params[ $param ]); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | /** |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | if (is_array($key)) { |
476 | 476 | $query = array_merge($query, $key); |
477 | 477 | } else { |
478 | - $query[$key] = $value; |
|
478 | + $query[ $key ] = $value; |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | $request_uri = $this->uri(); |
@@ -484,6 +484,6 @@ discard block |
||
484 | 484 | $request_uri = strstr($request_uri, '?', true); |
485 | 485 | } |
486 | 486 | |
487 | - return $request_uri . (!empty($query) ? '?' . http_build_query($query) : null); |
|
487 | + return $request_uri.(!empty($query) ? '?'.http_build_query($query) : null); |
|
488 | 488 | } |
489 | 489 | } |
@@ -47,10 +47,10 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function __get($name) |
49 | 49 | { |
50 | - if (!isset($this->services[$name])) { |
|
51 | - throw new UnknownServiceException('Unknown service '. $name); |
|
50 | + if (!isset($this->services[ $name ])) { |
|
51 | + throw new UnknownServiceException('Unknown service '.$name); |
|
52 | 52 | } |
53 | - $service = $this->services[$name]; |
|
53 | + $service = $this->services[ $name ]; |
|
54 | 54 | |
55 | 55 | return $service(); |
56 | 56 | } |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function __call($method, $args) |
70 | 70 | { |
71 | - if (!isset($this->services[$method]) || !is_callable($this->services[$method])) { |
|
72 | - throw new BadMethodCallException('Unknown method '. $method .'()'); |
|
71 | + if (!isset($this->services[ $method ]) || !is_callable($this->services[ $method ])) { |
|
72 | + throw new BadMethodCallException('Unknown method '.$method.'()'); |
|
73 | 73 | } |
74 | 74 | |
75 | - return call_user_func_array($this->services[$method], $args); |
|
75 | + return call_user_func_array($this->services[ $method ], $args); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function register($name, $closure) |
87 | 87 | { |
88 | - if (isset($this->services[$name])) { |
|
89 | - throw new DuplicateServiceException('A service is already registered under '. $name); |
|
88 | + if (isset($this->services[ $name ])) { |
|
89 | + throw new DuplicateServiceException('A service is already registered under '.$name); |
|
90 | 90 | } |
91 | 91 | |
92 | - $this->services[$name] = function () use ($closure) { |
|
92 | + $this->services[ $name ] = function() use ($closure) { |
|
93 | 93 | static $instance; |
94 | 94 | if (null === $instance) { |
95 | 95 | $instance = $closure(); |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | |
77 | 77 | // If a custom regular expression (or negated custom regex) |
78 | 78 | if ($this->namespace && |
79 | - (isset($path[0]) && $path[0] === '@') || |
|
80 | - (isset($path[0]) && $path[0] === '!' && isset($path[1]) && $path[1] === '@') |
|
79 | + (isset($path[ 0 ]) && $path[ 0 ] === '@') || |
|
80 | + (isset($path[ 0 ]) && $path[ 0 ] === '!' && isset($path[ 1 ]) && $path[ 1 ] === '@') |
|
81 | 81 | ) { |
82 | 82 | // Is it negated? |
83 | - if ($path[0] === '!') { |
|
83 | + if ($path[ 0 ] === '!') { |
|
84 | 84 | $negate = true; |
85 | 85 | $path = substr($path, 2); |
86 | 86 | } else { |
@@ -89,24 +89,24 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | // Regex anchored to front of string |
92 | - if ($path[0] === '^') { |
|
92 | + if ($path[ 0 ] === '^') { |
|
93 | 93 | $path = substr($path, 1); |
94 | 94 | } else { |
95 | - $path = '.*' . $path; |
|
95 | + $path = '.*'.$path; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | if ($negate) { |
99 | - $path = '@^' . $this->namespace . '(?!' . $path . ')'; |
|
99 | + $path = '@^'.$this->namespace.'(?!'.$path.')'; |
|
100 | 100 | } else { |
101 | - $path = '@^' . $this->namespace . $path; |
|
101 | + $path = '@^'.$this->namespace.$path; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | } elseif ($this->namespace && $this->pathIsNull($path)) { |
105 | 105 | // Empty route with namespace is a match-all |
106 | - $path = '@^' . $this->namespace . '(/|$)'; |
|
106 | + $path = '@^'.$this->namespace.'(/|$)'; |
|
107 | 107 | } else { |
108 | 108 | // Just prepend our namespace |
109 | - $path = $this->namespace . $path; |
|
109 | + $path = $this->namespace.$path; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | return $path; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function __construct($body = '', $status_code = null, array $headers = array()) |
109 | 109 | { |
110 | - $status_code = $status_code ?: static::$default_status_code; |
|
110 | + $status_code = $status_code ?: static::$default_status_code; |
|
111 | 111 | |
112 | 112 | // Set our body and code using our internal methods |
113 | 113 | $this->body($body); |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | // Require that the response be unlocked before changing it |
230 | 230 | $this->requireUnlocked(); |
231 | 231 | |
232 | - $this->body = $content . $this->body; |
|
232 | + $this->body = $content.$this->body; |
|
233 | 233 | |
234 | 234 | return $this; |
235 | 235 | } |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | |
334 | 334 | // Iterate through our Headers data collection and send each header |
335 | 335 | foreach ($this->headers as $key => $value) { |
336 | - header($key .': '. $value, false); |
|
336 | + header($key.': '.$value, false); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | if ($cookies_also) { |
@@ -76,7 +76,7 @@ |
||
76 | 76 | $code = (null !== $previous) ? $previous->getCode() : null; |
77 | 77 | |
78 | 78 | $message = sprintf(static::MESSAGE_FORMAT, $route->getPath()); |
79 | - $message .= ' '. sprintf(static::FAILURE_MESSAGE_TITLE_FORMAT, $error); |
|
79 | + $message .= ' '.sprintf(static::FAILURE_MESSAGE_TITLE_FORMAT, $error); |
|
80 | 80 | |
81 | 81 | $exception = new static($message, $code, $previous); |
82 | 82 | $exception->setRoute($route); |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | */ |
150 | 150 | public function get($key, $default_val = null) |
151 | 151 | { |
152 | - if (isset($this->attributes[$key])) { |
|
153 | - return $this->attributes[$key]; |
|
152 | + if (isset($this->attributes[ $key ])) { |
|
153 | + return $this->attributes[ $key ]; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | return $default_val; |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function set($key, $value) |
167 | 167 | { |
168 | - $this->attributes[$key] = $value; |
|
168 | + $this->attributes[ $key ] = $value; |
|
169 | 169 | |
170 | 170 | return $this; |
171 | 171 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | */ |
236 | 236 | public function remove($key) |
237 | 237 | { |
238 | - unset($this->attributes[$key]); |
|
238 | + unset($this->attributes[ $key ]); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
@@ -92,7 +92,7 @@ |
||
92 | 92 | |
93 | 93 | } elseif (in_array($key, self::$http_nonprefixed_headers)) { |
94 | 94 | // Add our server attribute to our header array |
95 | - $headers[$key] = $value; |
|
95 | + $headers[ $key ] = $value; |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 |
@@ -57,7 +57,7 @@ |
||
57 | 57 | $obj = print_r($obj, true); |
58 | 58 | } |
59 | 59 | |
60 | - $this->append('<pre>' . htmlentities($obj, ENT_QUOTES) . "</pre><br />\n"); |
|
60 | + $this->append('<pre>'.htmlentities($obj, ENT_QUOTES)."</pre><br />\n"); |
|
61 | 61 | |
62 | 62 | return $this; |
63 | 63 | } |