Completed
Push — master ( 188443...8f2ae0 )
by Maik
06:56
created
src/Mvc/Application.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
      */
212 212
     public function registerView($view, $order = null, $applicationName = 'default')
213 213
     {
214
-        if (! class_exists($view)) {
214
+        if (!class_exists($view)) {
215 215
             throw new ViewException("No such view class {view} found", array(
216 216
                 'view' => $view
217 217
             ));
218 218
         }
219 219
         
220 220
         $v = new $view();
221
-        if (! $v instanceof View) {
221
+        if (!$v instanceof View) {
222 222
             throw new ViewException("View {view} is not in application scope", array(
223 223
                 'view' => $view
224 224
             ));
@@ -318,14 +318,14 @@  discard block
 block discarded – undo
318 318
      */
319 319
     public function registerController($controller, $applicationName = 'default')
320 320
     {
321
-    	if ( !$controller instanceof \Nkey\Caribu\Mvc\Controller\AbstractController ) {
322
-	        if (! class_exists($controller)) {
321
+    	if (!$controller instanceof \Nkey\Caribu\Mvc\Controller\AbstractController) {
322
+	        if (!class_exists($controller)) {
323 323
 	            throw new ControllerException("No such controller class {controller} found", array(
324 324
 	                'controller' => $controller
325 325
 	            ));
326 326
 	        }
327 327
 	        $c = new $controller();
328
-	        if (! ($c instanceof AbstractController)) {
328
+	        if (!($c instanceof AbstractController)) {
329 329
 	            throw new ControllerException("Controller {controller} is not in application scope", array(
330 330
 	                'controller' => $controller
331 331
 	            ));
@@ -374,12 +374,12 @@  discard block
 block discarded – undo
374 374
             'action' => $action
375 375
         ));
376 376
         
377
-        if ( null != $this->router && $this->router->hasRoute($action) ) {
377
+        if (null != $this->router && $this->router->hasRoute($action)) {
378 378
         	$controllerInstance = $this->router->route($action, $request);
379 379
         	$action = $request->getAction();
380 380
         }
381 381
         else {
382
-	        if (! isset($this->controllers[$applicationName][$controller])) {
382
+	        if (!isset($this->controllers[$applicationName][$controller])) {
383 383
 	            $this->getLogger()->error("[{remote}] No such controller {controller}", array(
384 384
 	                'remote' => $request->getRemoteHost(),
385 385
 	                'controller' => $controller
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 	        
391 391
 	        $controllerInstance = $this->controllers[$applicationName][$controller];
392 392
 	        assert($controllerInstance instanceof AbstractController);
393
-	        if (! $controllerInstance->hasAction($action)) {
393
+	        if (!$controllerInstance->hasAction($action)) {
394 394
 	            $this->getLogger()->error("[{remote}] No such action {action}", array(
395 395
 	                'remote' => $request->getRemoteHost(),
396 396
 	                'action' => $action
Please login to merge, or discard this patch.
src/Mvc/Util/RequestParser.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -19,14 +19,14 @@  discard block
 block discarded – undo
19 19
      *
20 20
      * @param Request $request
21 21
      */
22
-    private static function parseContextPrefix(Request &$request, $serverVars = array())
22
+    private static function parseContextPrefix(Request & $request, $serverVars = array())
23 23
     {
24 24
         // Since apache 2.3.13 we have now an additional index which provides the context
25 25
         if (isset($serverVars['CONTEXT_PREFIX']) && $serverVars['CONTEXT_PREFIX'] != '') {
26
-            $request->setContextPrefix( $serverVars['CONTEXT_PREFIX'] . '/' );
26
+            $request->setContextPrefix($serverVars['CONTEXT_PREFIX'].'/');
27 27
         } elseif (isset($serverVars['REDIRECT_BASE'])) {
28 28
             // Try to determine the context from redirect base
29
-            $request->setContextPrefix ( $serverVars['REDIRECT_BASE'] );
29
+            $request->setContextPrefix($serverVars['REDIRECT_BASE']);
30 30
         } elseif (isset($serverVars['SCRIPT_FILENAME']) && isset($serverVars['SCRIPT_NAME'])) {
31 31
             // Fallback - get context out of script path
32 32
             if (isset($serverVars['HTTP_HOST'])) {
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
      *
51 51
      * @return array Parsed parts for later usage
52 52
      */
53
-    private static function parseUri(Request &$request,
53
+    private static function parseUri(Request & $request,
54 54
     		$uri, $defaultController, $defaultAction)
55 55
     {
56 56
         // All beyond the context prefix is our application request uri
@@ -70,19 +70,19 @@  discard block
 block discarded – undo
70 70
         
71 71
         // Check if there was a controller requested
72 72
         if (count($parts) > 0) {
73
-            $request->setController( ucfirst(trim($parts[0])) );
73
+            $request->setController(ucfirst(trim($parts[0])));
74 74
             array_shift($parts);
75
-            if (! $request->getController()) {
76
-                $request->setController( $defaultController );
75
+            if (!$request->getController()) {
76
+                $request->setController($defaultController);
77 77
             }
78 78
         }
79 79
         
80 80
         // Check if there was an action requested
81 81
         if (count($parts) > 0) {
82
-            $request->setAction( trim($parts[0]) );
82
+            $request->setAction(trim($parts[0]));
83 83
             array_shift($parts);
84
-            if (! $request->getAction()) {
85
-                $request->setAction( $defaultAction );
84
+            if (!$request->getAction()) {
85
+                $request->setAction($defaultAction);
86 86
             }
87 87
         }
88 88
         
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
      * @param string $paramName
102 102
      *            The destination parameter name
103 103
      */
104
-    private static function parseElement(Request &$req,
104
+    private static function parseElement(Request & $req,
105 105
     		$serverVars, $elementName, $paramName)
106 106
     {
107 107
         if (isset($serverVars[$elementName])) {
108
-        	$req->setParam( $paramName, $serverVars[$elementName] );
108
+        	$req->setParam($paramName, $serverVars[$elementName]);
109 109
         }
110 110
     }
111 111
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
      * @param array $serverVars
118 118
      *            The server variables provided by sapi
119 119
      */
120
-    private static function parseParameters(Request &$req, $serverVars)
120
+    private static function parseParameters(Request & $req, $serverVars)
121 121
     {
122 122
         self::parseElement($req, $serverVars, 'HTTP_ACCEPT', 'Accept');
123 123
         self::parseElement($req, $serverVars, 'HTTP_ACCEPT_LANGUAGE', 'Accept-Language');
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
      *
149 149
      * @param Request $request
150 150
      */
151
-    private static function parseRemoteHost(Request &$request, $serverVars = array())
151
+    private static function parseRemoteHost(Request & $request, $serverVars = array())
152 152
     {
153 153
         if (isset($serverVars['REMOTE_ADDR'])) {
154 154
             $request->remoteHost = $serverVars['REMOTE_ADDR'];
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      * @param Request $request
165 165
      *            Request object to put the parameters in
166 166
      */
167
-    private static function parseGetPostSessionCookie(Request &$request)
167
+    private static function parseGetPostSessionCookie(Request & $request)
168 168
     {
169 169
         foreach ($_GET as $name => $value) {
170 170
             $request->params[$name] = $value;
Please login to merge, or discard this patch.
src/Mvc/Controller/Request.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
      */
149 149
     public static function parseFromServerRequest($serverVars, $defaultController = 'Index', $defaultAction = 'index')
150 150
     {
151
-        if (! isset($serverVars['REQUEST_URI'])) {
151
+        if (!isset($serverVars['REQUEST_URI'])) {
152 152
             throw new InvalidUrlException("No such uri provided");
153 153
         }
154 154
         return self::parse($serverVars['REQUEST_URI'], $serverVars, $defaultController, $defaultAction);
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
         switch ($typeOf) {
273 273
             case 'bool':
274 274
             case 'boolean':
275
-                $result = function_exists('boolval') ? boolval($result) : (bool) $result;
275
+                $result = function_exists('boolval') ? boolval($result) : (bool)$result;
276 276
                 break;
277 277
             
278 278
             case 'double':
Please login to merge, or discard this patch.
src/Mvc/Router/AbstractRouter.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	public function setApplication(Application $application)
18 18
 	{
19 19
 		$this->application = $application;
20
-		foreach($this->routes as $routeName => $controller) {
20
+		foreach ($this->routes as $routeName => $controller) {
21 21
 			$this->application->registerController($controller, $routeName);
22 22
 		}
23 23
 	}
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 */
52 52
 	private function getRoute(string $name)
53 53
 	{
54
-		if(!$this->hasRoute($name)) {
54
+		if (!$this->hasRoute($name)) {
55 55
 			throw new RouterException("Router {$router} is not registered");
56 56
 		}
57 57
 		
@@ -69,13 +69,13 @@  discard block
 block discarded – undo
69 69
 	{
70 70
 		$parts = \explode('/', $request->getOrigin());
71 71
 		$found = false;
72
-		for($i = 0; $i < count($parts); $i++) {
73
-			if($parts[$i] === $name && isset($parts[$i+1])) {
74
-				$request->setAction($parts[$i+1]);
72
+		for ($i = 0; $i < count($parts); $i++) {
73
+			if ($parts[$i] === $name && isset($parts[$i + 1])) {
74
+				$request->setAction($parts[$i + 1]);
75 75
 				$found = true;
76 76
 			}
77 77
 		}
78
-		if(!$found) {
78
+		if (!$found) {
79 79
 			$request->setAction("index");
80 80
 		}
81 81
 		return $this->getRoute($name);
Please login to merge, or discard this patch.