Completed
Push — master ( ed6a51...b54114 )
by Tolan
36s queued 12s
created
lib/Template/TwigTemplate.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@
 block discarded – undo
100 100
 
101 101
         if (class_exists( "Puli\\TwigExtension\\PuliExtension" ) && null !== $this->repo) {
102 102
             $loader = new \Twig_Loader_Chain( [ new PuliTemplateLoader( $this->repo ), new Twig_Loader_String() ] );
103
-        }else {
103
+        } else {
104 104
             $loader = new Twig_Loader_String();
105 105
         }
106 106
         return $loader;
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -57,15 +57,15 @@  discard block
 block discarded – undo
57 57
         $templatePath = null,
58 58
         $templateString = null,
59 59
         ResourceRepository $repo = null
60
-    ){
61
-        parent::__construct( $component );
60
+    ) {
61
+        parent::__construct($component);
62 62
         $this->templatePath = $templatePath;
63 63
         $this->templateString = $templateString;
64 64
         // Optional Puli repo
65 65
         $this->repo = $repo;
66 66
 
67 67
         Twig_Autoloader::register();
68
-        $this->initTwig( $this->getLoader() );
68
+        $this->initTwig($this->getLoader());
69 69
     }
70 70
 
71 71
     /**
@@ -73,15 +73,15 @@  discard block
 block discarded – undo
73 73
      * @param array $props
74 74
      * @return Response
75 75
      */
76
-    protected function doRender( ViewState $state, array $props = [] )
76
+    protected function doRender(ViewState $state, array $props = [ ])
77 77
     {
78 78
         // If puli plugin is available then add it.
79
-        if (class_exists( "Puli\\TwigExtension\\PuliExtension" ) && null !== $this->repo) {
80
-            $this->twig->addExtension( new PuliExtension( $this->repo ) );
79
+        if (class_exists("Puli\\TwigExtension\\PuliExtension") && null !== $this->repo) {
80
+            $this->twig->addExtension(new PuliExtension($this->repo));
81 81
         }
82 82
 
83 83
         $rendered = $this->twig->render(
84
-            $this->templateString?$this->templateString:$this->templatePath,
84
+            $this->templateString ? $this->templateString : $this->templatePath,
85 85
             [
86 86
                 'state' => $state,
87 87
                 'props' => $props,
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
                 'parent' => $this->component->getParent(),
90 90
                 'exec' => $this->component->exec
91 91
             ] );
92
-        return new Response( "text/html", $rendered );
92
+        return new Response("text/html", $rendered);
93 93
     }
94 94
 
95 95
     /**
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
     protected function getLoader()
99 99
     {
100 100
 
101
-        if (class_exists( "Puli\\TwigExtension\\PuliExtension" ) && null !== $this->repo) {
102
-            $loader = new \Twig_Loader_Chain( [ new PuliTemplateLoader( $this->repo ), new Twig_Loader_String() ] );
101
+        if (class_exists("Puli\\TwigExtension\\PuliExtension") && null !== $this->repo) {
102
+            $loader = new \Twig_Loader_Chain([ new PuliTemplateLoader($this->repo), new Twig_Loader_String() ]);
103 103
         }else {
104 104
             $loader = new Twig_Loader_String();
105 105
         }
@@ -109,13 +109,13 @@  discard block
 block discarded – undo
109 109
     /**
110 110
      * @param $loader
111 111
      */
112
-    protected function initTwig( $loader )
112
+    protected function initTwig($loader)
113 113
     {
114 114
         $config = [ 'autoescape' => false ];
115
-        if (defined( "TWIG_CACHE_DIR" )) {
115
+        if (defined("TWIG_CACHE_DIR")) {
116 116
             $config[ 'cache' ] = TWIG_CACHE_DIR;
117 117
         }
118
-        $this->twig = new Twig_Environment( $loader, $config );
118
+        $this->twig = new Twig_Environment($loader, $config);
119 119
     }
120 120
 
121 121
 }
Please login to merge, or discard this patch.
lib/Template/PhpTemplate.php 2 patches
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -86,11 +86,11 @@
 block discarded – undo
86 86
             /** @noinspection PhpIncludeInspection */
87 87
             include( $realPath );
88 88
             $rendered = ob_get_clean();
89
-        }elseif ($this->templateString) {
89
+        } elseif ($this->templateString) {
90 90
             ob_start();
91 91
             eval( "?>" . $this->templateString );
92 92
             $rendered = ob_get_clean();
93
-        }else {
93
+        } else {
94 94
             throw new \Exception( "Neither valid template path no valid template string passed to PhpTemplate." );
95 95
         }
96 96
 
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
         $templatePath = null,
52 52
         $templateString = null,
53 53
         ResourceRepository $repo = null
54
-    ){
55
-        parent::__construct( $component );
54
+    ) {
55
+        parent::__construct($component);
56 56
         $this->templatePath = $templatePath;
57 57
         $this->templateString = $templateString;
58 58
         // Optional Puli repo
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      * @return Response
66 66
      * @throws \Exception
67 67
      */
68
-    protected function doRender( ViewState $state, array $props = [ ] )
68
+    protected function doRender(ViewState $state, array $props = [ ])
69 69
     {
70 70
         // Available variables in template file are:
71 71
         // $state
@@ -81,20 +81,20 @@  discard block
 block discarded – undo
81 81
         /** @noinspection PhpUnusedLocalVariableInspection */
82 82
         $exec = $this->component->exec;
83 83
         if ($this->templatePath) {
84
-            $realPath = $this->getRealTemplatePath( $this->templatePath );
84
+            $realPath = $this->getRealTemplatePath($this->templatePath);
85 85
             ob_start();
86 86
             /** @noinspection PhpIncludeInspection */
87
-            include( $realPath );
87
+            include($realPath);
88 88
             $rendered = ob_get_clean();
89 89
         }elseif ($this->templateString) {
90 90
             ob_start();
91
-            eval( "?>" . $this->templateString );
91
+            eval("?>".$this->templateString);
92 92
             $rendered = ob_get_clean();
93 93
         }else {
94
-            throw new \Exception( "Neither valid template path no valid template string passed to PhpTemplate." );
94
+            throw new \Exception("Neither valid template path no valid template string passed to PhpTemplate.");
95 95
         }
96 96
 
97
-        return new Response( "text/html", $rendered );
97
+        return new Response("text/html", $rendered);
98 98
     }
99 99
 
100 100
     /**
@@ -102,18 +102,18 @@  discard block
 block discarded – undo
102 102
      * @return null|string
103 103
      * @throws \Exception
104 104
      */
105
-    private function getRealTemplatePath( $templatePath )
105
+    private function getRealTemplatePath($templatePath)
106 106
     {
107 107
         if ($this->repo instanceof ResourceRepository) {
108
-            if ($this->repo->contains( $templatePath )) {
109
-                return $this->repo->get( $templatePath )
108
+            if ($this->repo->contains($templatePath)) {
109
+                return $this->repo->get($templatePath)
110 110
                     ->getFilesystemPath();
111 111
             }
112 112
         }
113
-        if (file_exists( $templatePath )) {
113
+        if (file_exists($templatePath)) {
114 114
             return $templatePath;
115 115
         }
116
-        throw new \Exception( "Template path not found in repository or on filesystem: {$templatePath}, in PhpTemplate" );
116
+        throw new \Exception("Template path not found in repository or on filesystem: {$templatePath}, in PhpTemplate");
117 117
     }
118 118
 
119 119
 }
Please login to merge, or discard this patch.
lib/AbstractViewComponent.php 2 patches
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
         if ($execMethodName) { // Used to test for null but it could easily be an empty string
186 186
             $this->log( "Rendering with exec: {$execMethodName}, args:".var_export($execArgs, true ), LogLevel::DEBUG );
187 187
             $out = $this->execMethod( $execMethodName, $execArgs );
188
-        }else {
188
+        } else {
189 189
             $this->log( "Rendering without exec", LogLevel::DEBUG );
190 190
             $out = $this->template->render( $this->state, $this->props );
191 191
             if (!( $out instanceof Response )) {
@@ -211,12 +211,12 @@  discard block
 block discarded – undo
211 211
         if (count( $methodName ) == 1) {
212 212
             $methodName = $methodName[ 0 ] . 'Handler';
213 213
             $out = $this->$methodName( $args );
214
-        }else {
214
+        } else {
215 215
             $childName = array_shift( $methodName );
216 216
             $child = $this->childComponents[ $childName ];
217 217
             if ($child instanceof AbstractViewComponent) {
218 218
                 $out = $child->execMethod( $methodName, $args );
219
-            }else {
219
+            } else {
220 220
                 throw new \Exception( implode( ".", $methodName ) . " is not a valid method." );
221 221
             }
222 222
         }
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
         }
302 302
         if (null !== ( $pPath = $this->parent->getPath() )) {
303 303
             return $pPath . '.' . $this->handle;
304
-        }else {
304
+        } else {
305 305
             return $this->handle;
306 306
         }
307 307
     }
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
             }
325 325
             $child = new $type( $handle, $this, $this->exec, $this->logger );
326 326
             $this->childComponents[ $handle ] = $child;
327
-        }else {
327
+        } else {
328 328
             // exec, di and logger are set recursively in rehydrate()
329 329
             $child = $this->childComponents[ $handle ];
330 330
         }
Please login to merge, or discard this patch.
Spacing   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
         AbstractViewComponent $parent = null,
90 90
         ExecHelper $execHelper = null,
91 91
         LoggerInterface $logger = null
92
-    ){
92
+    ) {
93 93
         // Null means we are root
94 94
         $this->parent = $parent;
95 95
 
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
         if (null === $execHelper) {
100 100
             $execHelper = new ExecHelper();
101 101
         }
102
-        $this->setExec( $execHelper );
102
+        $this->setExec($execHelper);
103 103
 
104 104
         $this->handleDependencyInjection();
105 105
         
106
-        $this->setLogger( $logger );
106
+        $this->setLogger($logger);
107 107
 
108 108
         // Set up the state container
109 109
         $this->initState();
@@ -113,14 +113,14 @@  discard block
 block discarded – undo
113 113
      * @param string $message
114 114
      * @param string $level A constant from LogLevel
115 115
      */
116
-    protected function log( $message, $level, $context = [] ){
117
-        if( isset( $this->logger ) ){
118
-            $class = get_class( $this );
116
+    protected function log($message, $level, $context = [ ]) {
117
+        if (isset($this->logger)) {
118
+            $class = get_class($this);
119 119
             $message = "[{$class}] {$message}";
120
-            if( ! is_array($context) ){
121
-                $context = [$context];
120
+            if (!is_array($context)) {
121
+                $context = [ $context ];
122 122
             }
123
-            $this->logger->log( $level, $message, $context );
123
+            $this->logger->log($level, $message, $context);
124 124
         }
125 125
     }
126 126
 
@@ -129,10 +129,10 @@  discard block
 block discarded – undo
129 129
      * Note that we have implemented __sleep() so not all members are serialised.
130 130
      * @return string
131 131
      */
132
-    public function dehydrate(){
132
+    public function dehydrate() {
133 133
         $ser = serialize($this);
134 134
         // We have to unserialise the serialised object here because it's stripped down to only the required properties by __sleep()
135
-        $this->log( "Dehydrating", LogLevel::DEBUG, [unserialize($ser)] );
135
+        $this->log("Dehydrating", LogLevel::DEBUG, [ unserialize($ser) ]);
136 136
         return $ser;
137 137
     }
138 138
 
@@ -144,15 +144,15 @@  discard block
 block discarded – undo
144 144
      * @param LoggerInterface $logger
145 145
      * @return AbstractViewComponent
146 146
      */
147
-    public static function rehydrate( $serialised, ExecHelper $execHelper, LoggerInterface $logger = null ){
147
+    public static function rehydrate($serialised, ExecHelper $execHelper, LoggerInterface $logger = null) {
148 148
         /** @var AbstractViewComponent $view */
149
-        $view = unserialize( $serialised );
150
-        if( null !== $logger ){
151
-            $logger->log( LogLevel::DEBUG, "Rehydrating", [$view] );
149
+        $view = unserialize($serialised);
150
+        if (null !== $logger) {
151
+            $logger->log(LogLevel::DEBUG, "Rehydrating", [ $view ]);
152 152
         }
153
-        $view->setExec( $execHelper );
153
+        $view->setExec($execHelper);
154 154
         $view->handleDependencyInjection();
155
-        $view->setLogger( $logger );
155
+        $view->setLogger($logger);
156 156
         return $view;
157 157
     }
158 158
 
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
      * @return mixed
175 175
      */
176 176
     public function jsonSerialize() {
177
-        $ret = [];
177
+        $ret = [ ];
178 178
         // Return the same fields as __sleep() specifies for serialize()
179
-        foreach ( $this->__sleep() as $member ){
179
+        foreach ($this->__sleep() as $member) {
180 180
             // Skip parent because recursion isn't supported
181
-            if( $member == 'parent'){
181
+            if ($member == 'parent') {
182 182
                 continue;
183 183
             }
184
-            $ret[$member] = $this->$member;
184
+            $ret[ $member ] = $this->$member;
185 185
         }
186 186
         return $ret;
187 187
     }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
      * @throws \Exception
194 194
      * @return Response
195 195
      */
196
-    public function render( $execMethodName = null, array $execArgs = null )
196
+    public function render($execMethodName = null, array $execArgs = null)
197 197
     {
198 198
         $this->state->validate();
199 199
 
@@ -208,13 +208,13 @@  discard block
 block discarded – undo
208 208
         // If we're called with an 'exec' then run it instead of rendering the whole tree.
209 209
         // It may still render the whole tree or it may just render a portion or just return JSON
210 210
         if ($execMethodName) { // Used to test for null but it could easily be an empty string
211
-            $this->log( "Rendering with exec: {$execMethodName}, args:".var_export($execArgs, true ), LogLevel::DEBUG );
212
-            $out = $this->execMethod( $execMethodName, $execArgs );
211
+            $this->log("Rendering with exec: {$execMethodName}, args:".var_export($execArgs, true), LogLevel::DEBUG);
212
+            $out = $this->execMethod($execMethodName, $execArgs);
213 213
         }else {
214
-            $this->log( "Rendering without exec", LogLevel::DEBUG );
215
-            $out = $this->template->render( $this->state, $this->props );
216
-            if (!( $out instanceof Response )) {
217
-                throw new \Exception( get_class( $this->template ) . " returned invalid response. Should have been an instance of PatternSeek\ComponentView\Response" );
214
+            $this->log("Rendering without exec", LogLevel::DEBUG);
215
+            $out = $this->template->render($this->state, $this->props);
216
+            if (!($out instanceof Response)) {
217
+                throw new \Exception(get_class($this->template)." returned invalid response. Should have been an instance of PatternSeek\ComponentView\Response");
218 218
             }
219 219
         }
220 220
         return $out;
@@ -228,26 +228,26 @@  discard block
 block discarded – undo
228 228
      * @throws \Exception
229 229
      * @return Response
230 230
      */
231
-    protected function execMethod( $methodName, array $args = null )
231
+    protected function execMethod($methodName, array $args = null)
232 232
     {
233
-        if (!is_array( $methodName )) {
234
-            $methodName = explode( '.', $methodName );
233
+        if (!is_array($methodName)) {
234
+            $methodName = explode('.', $methodName);
235 235
         }
236
-        if (count( $methodName ) == 1) {
237
-            $methodName = $methodName[ 0 ] . 'Handler';
238
-            $out = $this->$methodName( $args );
236
+        if (count($methodName) == 1) {
237
+            $methodName = $methodName[ 0 ].'Handler';
238
+            $out = $this->$methodName($args);
239 239
         }else {
240
-            $childName = array_shift( $methodName );
240
+            $childName = array_shift($methodName);
241 241
             $child = $this->childComponents[ $childName ];
242 242
             if ($child instanceof AbstractViewComponent) {
243
-                $out = $child->execMethod( $methodName, $args );
243
+                $out = $child->execMethod($methodName, $args);
244 244
             }else {
245
-                throw new \Exception( implode( ".", $methodName ) . " is not a valid method." );
245
+                throw new \Exception(implode(".", $methodName)." is not a valid method.");
246 246
             }
247 247
         }
248
-        if (!( $out instanceof Response )) {
249
-            $nameStr = is_array( $methodName )?implode( ".", $methodName ):$methodName;
250
-            throw new \Exception( $nameStr . " returned invalid response. Should have been an instance of PatternSeek\ComponentView\Response" );
248
+        if (!($out instanceof Response)) {
249
+            $nameStr = is_array($methodName) ?implode(".", $methodName) : $methodName;
250
+            throw new \Exception($nameStr." returned invalid response. Should have been an instance of PatternSeek\ComponentView\Response");
251 251
         }
252 252
         return $out;
253 253
     }
@@ -256,10 +256,10 @@  discard block
 block discarded – undo
256 256
      * @param $execMethod
257 257
      * @return string
258 258
      */
259
-    public function getExecPath( $execMethod )
259
+    public function getExecPath($execMethod)
260 260
     {
261 261
         $path = $this->getPath();
262
-        return ( $path === null?$execMethod:$path . '.' . $execMethod );
262
+        return ($path === null ? $execMethod : $path.'.'.$execMethod);
263 263
     }
264 264
 
265 265
     /**
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
     /**
275 275
      * @param $string
276 276
      */
277
-    protected function setFlashMessage( $string )
277
+    protected function setFlashMessage($string)
278 278
     {
279 279
         $this->flashMessage = $string;
280 280
     }
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
     /**
283 283
      * @param $string
284 284
      */
285
-    protected function setFlashError( $string )
285
+    protected function setFlashError($string)
286 286
     {
287 287
         $this->flashError = $string;
288 288
     }
@@ -324,8 +324,8 @@  discard block
 block discarded – undo
324 324
         if (null === $this->parent) {
325 325
             return null;
326 326
         }
327
-        if (null !== ( $pPath = $this->parent->getPath() )) {
328
-            return $pPath . '.' . $this->handle;
327
+        if (null !== ($pPath = $this->parent->getPath())) {
328
+            return $pPath.'.'.$this->handle;
329 329
         }else {
330 330
             return $this->handle;
331 331
         }
@@ -340,20 +340,20 @@  discard block
 block discarded – undo
340 340
      * @return AbstractViewComponent
341 341
      * @throws \Exception
342 342
      */
343
-    protected function addOrUpdateChild( $handle, $type, array $props = [ ] )
343
+    protected function addOrUpdateChild($handle, $type, array $props = [ ])
344 344
     {
345
-        $this->log( "Adding/updating child '{$handle}' of type {$type}", LogLevel::DEBUG );
346
-        if (!isset( $this->childComponents[ $handle ] )) {
347
-            if( ! class_exists( $type ) ){
348
-                throw new \Exception( "Class '{$type}' for sub-component  does not exist." );
345
+        $this->log("Adding/updating child '{$handle}' of type {$type}", LogLevel::DEBUG);
346
+        if (!isset($this->childComponents[ $handle ])) {
347
+            if (!class_exists($type)) {
348
+                throw new \Exception("Class '{$type}' for sub-component  does not exist.");
349 349
             }
350
-            $child = new $type( $handle, $this, $this->exec, $this->logger );
350
+            $child = new $type($handle, $this, $this->exec, $this->logger);
351 351
             $this->childComponents[ $handle ] = $child;
352 352
         }else {
353 353
             // exec, di and logger are set recursively in rehydrate()
354 354
             $child = $this->childComponents[ $handle ];
355 355
         }
356
-        $child->updateProps( $props );
356
+        $child->updateProps($props);
357 357
         $child->updateState();
358 358
     }
359 359
 
@@ -364,12 +364,12 @@  discard block
 block discarded – undo
364 364
      * @return Response
365 365
      * @throws \Exception
366 366
      */
367
-    public function renderChild( $handle )
367
+    public function renderChild($handle)
368 368
     {
369 369
         if (!$this->childComponents[ $handle ]) {
370 370
             $message = "Attempted to render nonexistent child component with handle '{$handle}'";
371
-            $this->log( $message, LogLevel::CRITICAL );
372
-            throw new \Exception( $message );
371
+            $this->log($message, LogLevel::CRITICAL);
372
+            throw new \Exception($message);
373 373
         }
374 374
         return $this->childComponents[ $handle ]->render()->content;
375 375
     }
@@ -417,79 +417,79 @@  discard block
 block discarded – undo
417 417
      * @param array $inputs
418 418
      * @throws \Exception
419 419
      */
420
-    protected function testInputs( array $inputSpec, array &$inputs )
420
+    protected function testInputs(array $inputSpec, array &$inputs)
421 421
     {
422 422
         
423 423
         foreach ($inputSpec as $fieldName => $fieldSpec) {
424 424
             // Required field
425
-            if (( count( $fieldSpec ) < 2 )) {
426
-                if (!isset( $inputs[ $fieldName ] )) {
427
-                    $calledFunc = debug_backtrace()[1]['function'];
428
-                    $callerFunc = debug_backtrace()[2]['function'];
429
-                    $callerClass = debug_backtrace()[2]['class'];
425
+            if ((count($fieldSpec) < 2)) {
426
+                if (!isset($inputs[ $fieldName ])) {
427
+                    $calledFunc = debug_backtrace()[ 1 ][ 'function' ];
428
+                    $callerFunc = debug_backtrace()[ 2 ][ 'function' ];
429
+                    $callerClass = debug_backtrace()[ 2 ][ 'class' ];
430 430
                     $parentText = '';
431
-                    if( $this->parent !== null ){
431
+                    if ($this->parent !== null) {
432 432
                         $parentText = " (parent component is ".get_class($this->parent).")";
433 433
                     }
434
-                    throw new \Exception( $fieldName . " is a required field for " . get_class( $this )."::{$calledFunc}() called from {$callerClass}::{$callerFunc}(){$parentText}" );
434
+                    throw new \Exception($fieldName." is a required field for ".get_class($this)."::{$calledFunc}() called from {$callerClass}::{$callerFunc}(){$parentText}");
435 435
                 }
436 436
             }
437 437
             // Set default is unset
438
-            if (!isset( $inputs[ $fieldName ] )) {
438
+            if (!isset($inputs[ $fieldName ])) {
439 439
                 $inputs[ $fieldName ] = $fieldSpec[ 1 ];
440 440
             }
441 441
             // Check type
442 442
             // Any type allowed, continue
443
-            if (!isset( $fieldSpec[ 0 ] ) || $fieldSpec[ 0 ] === null) {
443
+            if (!isset($fieldSpec[ 0 ]) || $fieldSpec[ 0 ] === null) {
444 444
                 continue;
445 445
             }
446 446
             $requiredType = $fieldSpec[ 0 ];
447 447
             $input = $inputs[ $fieldName ];
448 448
             // Specific type required
449 449
             // Null is allowed
450
-            if (!is_null( $input )) {
450
+            if (!is_null($input)) {
451 451
                 switch ($requiredType) {
452 452
                     case "boolean":
453 453
                     case "bool":
454
-                    $failed = !is_bool( $input );
454
+                    $failed = !is_bool($input);
455 455
                         break;
456 456
                     case "integer":
457 457
                     case "int":
458
-                    $failed = !is_int( $input+0 );
458
+                    $failed = !is_int($input + 0);
459 459
                         break;
460 460
                     case "double":
461
-                        $failed = !is_double( $input+0 );
461
+                        $failed = !is_double($input + 0);
462 462
                         break;
463 463
                     case "float":
464
-                        $failed = !is_float( $input+0 );
464
+                        $failed = !is_float($input + 0);
465 465
                         break;
466 466
                     case "string":
467
-                        $failed = !is_string( $input );
467
+                        $failed = !is_string($input);
468 468
                         break;
469 469
                     case "array":
470
-                        $failed = !is_array( $input );
470
+                        $failed = !is_array($input);
471 471
                         break;
472 472
                     case "object":
473
-                        $failed = !is_object( $input );
473
+                        $failed = !is_object($input);
474 474
                         break;
475 475
                     case "resource":
476
-                        $failed = !is_resource( $input );
476
+                        $failed = !is_resource($input);
477 477
                         break;
478 478
                     case "callable":
479
-                        $failed = !is_callable( $input );
479
+                        $failed = !is_callable($input);
480 480
                         break;
481 481
                     default:
482
-                        $failed = !( $input instanceof $requiredType );
482
+                        $failed = !($input instanceof $requiredType);
483 483
                 }
484 484
                 if ($failed) {
485
-                    $calledFunc = debug_backtrace()[1]['function'];
486
-                    $callerFunc = debug_backtrace()[2]['function'];
487
-                    $callerClass = debug_backtrace()[2]['class'];
485
+                    $calledFunc = debug_backtrace()[ 1 ][ 'function' ];
486
+                    $callerFunc = debug_backtrace()[ 2 ][ 'function' ];
487
+                    $callerClass = debug_backtrace()[ 2 ][ 'class' ];
488 488
                     $parentText = '';
489
-                    if( $this->parent !== null ){
489
+                    if ($this->parent !== null) {
490 490
                         $parentText = " (parent component is ".get_class($this->parent).")";
491 491
                     }
492
-                    throw new \Exception( $fieldName . " should be of type " . $requiredType . "in " . get_class( $this )."::{$calledFunc}() called from {$callerClass}::{$callerFunc}(){$parentText}" );
492
+                    throw new \Exception($fieldName." should be of type ".$requiredType."in ".get_class($this)."::{$calledFunc}() called from {$callerClass}::{$callerFunc}(){$parentText}");
493 493
                 }
494 494
             }
495 495
         }
@@ -500,9 +500,9 @@  discard block
 block discarded – undo
500 500
      *
501 501
      * @var array $props
502 502
      */
503
-    public function updateView( $props )
503
+    public function updateView($props)
504 504
     {
505
-        $this->updateProps( $props );
505
+        $this->updateProps($props);
506 506
         $this->updateState();
507 507
     }
508 508
 
@@ -511,13 +511,13 @@  discard block
 block discarded – undo
511 511
      *
512 512
      * @var array $props
513 513
      */
514
-    protected function updateProps( $props )
514
+    protected function updateProps($props)
515 515
     {
516
-        $this->log( "Storing new props: ", LogLevel::DEBUG,  var_export( $props, true ) );
516
+        $this->log("Storing new props: ", LogLevel::DEBUG, var_export($props, true));
517 517
         $this->props = $props;   
518 518
     }
519 519
 
520
-    protected function forceResponse( Response $response )
520
+    protected function forceResponse(Response $response)
521 521
     {
522 522
         $this->forceResponse = $response;
523 523
     }
@@ -525,12 +525,12 @@  discard block
 block discarded – undo
525 525
     /**
526 526
      * @param ExecHelper $execHelper
527 527
      */
528
-    private function setExec( ExecHelper $execHelper )
528
+    private function setExec(ExecHelper $execHelper)
529 529
     {
530 530
         $this->exec = clone $execHelper;
531
-        $this->exec->setComponent( $this );
532
-        foreach( $this->childComponents as $child ){
533
-            $child->setExec( $execHelper );
531
+        $this->exec->setComponent($this);
532
+        foreach ($this->childComponents as $child) {
533
+            $child->setExec($execHelper);
534 534
         }
535 535
     }
536 536
 
@@ -544,9 +544,9 @@  discard block
 block discarded – undo
544 544
         // it manually and you still get the advantage that the deps
545 545
         // are specified in the optional injectDependencies() method's
546 546
         // signature
547
-        $this->log( "Dependency injection...", LogLevel::DEBUG );
548
-        DependencyInjector::instance()->injectIntoMethod( $this );
549
-        foreach( $this->childComponents as $child ){
547
+        $this->log("Dependency injection...", LogLevel::DEBUG);
548
+        DependencyInjector::instance()->injectIntoMethod($this);
549
+        foreach ($this->childComponents as $child) {
550 550
             $child->handleDependencyInjection();
551 551
         }
552 552
     }
@@ -554,13 +554,13 @@  discard block
 block discarded – undo
554 554
     /**
555 555
      * @param LoggerInterface $logger
556 556
      */
557
-    private function setLogger( LoggerInterface $logger = null )
557
+    private function setLogger(LoggerInterface $logger = null)
558 558
     {
559
-        if( null !== $logger ){
559
+        if (null !== $logger) {
560 560
             $this->logger = $logger;
561 561
             /** @var AbstractViewComponent $child */
562
-            foreach( $this->childComponents as $child ){
563
-                $child->setLogger( $logger );
562
+            foreach ($this->childComponents as $child) {
563
+                $child->setLogger($logger);
564 564
             }
565 565
         }
566 566
     }
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
     /**
569 569
      * @return LoggerInterface
570 570
      */
571
-    protected function getLogger(){
571
+    protected function getLogger() {
572 572
         return $this->logger;
573 573
     }
574 574
 }
Please login to merge, or discard this patch.
lib/Response.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -40,16 +40,16 @@
 block discarded – undo
40 40
      * @param string $content
41 41
      * @param int|null $responseCode
42 42
      */
43
-    public function __construct( $type, $content, $responseCode = null )
43
+    public function __construct($type, $content, $responseCode = null)
44 44
     {
45 45
         $this->type = $type;
46 46
         $this->content = $content;
47 47
         
48 48
         // Response code defaults
49 49
         if (null === $responseCode) {
50
-            if( $type == "redirect" ){
50
+            if ($type == "redirect") {
51 51
                 $responseCode = 302;
52
-            }else{
52
+            }else {
53 53
                 $responseCode = 200;
54 54
             }
55 55
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
         if (null === $responseCode) {
50 50
             if( $type == "redirect" ){
51 51
                 $responseCode = 302;
52
-            }else{
52
+            } else{
53 53
                 $responseCode = 200;
54 54
             }
55 55
         }
Please login to merge, or discard this patch.
lib/Template/AbstractTemplate.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * Class AbstractTemplate
26 26
  * @package PatternSeek\ComponentView
27 27
  */
28
-abstract class AbstractTemplate{
28
+abstract class AbstractTemplate {
29 29
 
30 30
     /**
31 31
      * @var AbstractViewComponent
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     /**
36 36
      * @param AbstractViewComponent $component
37 37
      */
38
-    public function __construct( AbstractViewComponent $component ){
38
+    public function __construct(AbstractViewComponent $component) {
39 39
         $this->component = $component;
40 40
     }
41 41
 
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
      * @param array $props
46 46
      * @return Response
47 47
      */
48
-    public function render( ViewState $state, array $props = [] )
48
+    public function render(ViewState $state, array $props = [ ])
49 49
     {
50
-        return $this->doRender( $state, $props );
50
+        return $this->doRender($state, $props);
51 51
     }
52 52
 
53 53
     /**
@@ -55,6 +55,6 @@  discard block
 block discarded – undo
55 55
      * @param array $props
56 56
      * @return Response
57 57
      */
58
-    abstract protected function doRender( ViewState $state, array $props = [] );
58
+    abstract protected function doRender(ViewState $state, array $props = [ ]);
59 59
 
60 60
 }
Please login to merge, or discard this patch.
lib/ExecHelper.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
      */
19 19
     protected $component;
20 20
 
21
-    public function setComponent( AbstractViewComponent $component )
21
+    public function setComponent(AbstractViewComponent $component)
22 22
     {
23 23
         $this->component = $component;
24 24
     }
@@ -30,11 +30,11 @@  discard block
 block discarded – undo
30 30
      * @param bool $onlyComponentOutput
31 31
      * @return string A URL or URI
32 32
      */
33
-    public function url( $execMethod, $args = [ ], $onlyComponentOutput = false ) // $onlyComponentOutput Not used in this implementation but necessary for subclasses
33
+    public function url($execMethod, $args = [ ], $onlyComponentOutput = false) // $onlyComponentOutput Not used in this implementation but necessary for subclasses
34 34
     {
35 35
         // $onlyComponentOutput is not used in this implementation but may be by sub-classes
36
-        $args[ 'exec' ] = $this->component->getExecPath( $execMethod );
37
-        $qs = http_build_query( $args );
36
+        $args[ 'exec' ] = $this->component->getExecPath($execMethod);
37
+        $qs = http_build_query($args);
38 38
         return "?{$qs}";
39 39
     }
40 40
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         }
69 69
         return <<<EOS
70 70
 <form method="{$method}" action=""{$formID}{$onSubmit} enctype="{$encType}">
71
-    <input type="hidden" name="exec" value="{$this->component->getExecPath( $execMethod )}">
71
+    <input type="hidden" name="exec" value="{$this->component->getExecPath($execMethod)}">
72 72
     {$formBody}
73 73
 </form>
74 74
 EOS;
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     public function callStatic($class, $function, $args = array())
85 85
     {
86 86
         if (class_exists($class) && method_exists($class, $function)) {
87
-            return call_user_func_array( array( $class, $function ), $args );
87
+            return call_user_func_array(array($class, $function), $args);
88 88
         }
89 89
         return null;
90 90
     }
@@ -98,14 +98,14 @@  discard block
 block discarded – undo
98 98
      * @param array $anchorAttrs
99 99
      * @return string
100 100
      */
101
-    public function replaceElementUsingLink( $execMethod, $args = [ ], $targetDiv, $linkText, $anchorAttrs = [ ] )
101
+    public function replaceElementUsingLink($execMethod, $args = [ ], $targetDiv, $linkText, $anchorAttrs = [ ])
102 102
     {
103
-        $url = $this->url( $execMethod, $args, true );
103
+        $url = $this->url($execMethod, $args, true);
104 104
         $attrs = [ ];
105 105
         foreach ($anchorAttrs as $k => $v) {
106 106
             $attrs[ ] = "{$k}='{$v}'";
107 107
         }
108
-        $attrsStr = implode( ' ', $attrs );
108
+        $attrsStr = implode(' ', $attrs);
109 109
         return <<<EOS
110 110
         <script type="application/javascript">
111 111
             if( typeof(execLink) != "function" ){
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
      * @param string $encType
139 139
      * @return string
140 140
      */
141
-    public function replaceElementUsingForm( $execMethod, $method, $formBody, $targetDiv, $formID, $encType = 'application/x-www-form-urlencoded' )
141
+    public function replaceElementUsingForm($execMethod, $method, $formBody, $targetDiv, $formID, $encType = 'application/x-www-form-urlencoded')
142 142
     {
143 143
         return <<<EOS
144
-        {$this->wrapForm( $execMethod, $method, $formBody, true, $formID,
145
-            "execForm( this, \"{$targetDiv}\" ); return false;", $encType )}
144
+        {$this->wrapForm($execMethod, $method, $formBody, true, $formID,
145
+            "execForm( this, \"{$targetDiv}\" ); return false;", $encType)}
146 146
         <script type="application/javascript">
147 147
         if( typeof(execForm) != "function" ){
148 148
             var execForm = function( form, targetDiv ){
Please login to merge, or discard this patch.