Passed
Push — master ( fb679f...5d8234 )
by
unknown
01:37
created
src/Routing/Route.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -44,29 +44,29 @@  discard block
 block discarded – undo
44 44
 	 * @param mixed           $target
45 45
 	 * @param string|\Closure $handler
46 46
 	 */
47
-	public function __construct( $methods, $target, $handler ) {
48
-		if ( is_string( $target ) ) {
49
-			$target = new UrlCondition( $target );
47
+	public function __construct($methods, $target, $handler) {
48
+		if (is_string($target)) {
49
+			$target = new UrlCondition($target);
50 50
 		}
51 51
 
52
-		if ( is_array( $target ) ) {
53
-			$target = $this->condition( $target );
52
+		if (is_array($target)) {
53
+			$target = $this->condition($target);
54 54
 		}
55 55
 
56
-		if ( ! is_a( $target, ConditionInterface::class ) ) {
57
-			throw new Exception( 'Route target is not a valid route string or condition.' );
56
+		if ( ! is_a($target, ConditionInterface::class)) {
57
+			throw new Exception('Route target is not a valid route string or condition.');
58 58
 		}
59 59
 
60 60
 		$this->methods = $methods;
61 61
 		$this->target = $target;
62
-		$this->handler = new Handler( $handler );
62
+		$this->handler = new Handler($handler);
63 63
 	}
64 64
 
65 65
 	/**
66 66
 	 * {@inheritDoc}
67 67
 	 */
68 68
 	public function satisfied() {
69
-		if ( ! in_array( $_SERVER['REQUEST_METHOD'], $this->methods) ) {
69
+		if ( ! in_array($_SERVER['REQUEST_METHOD'], $this->methods)) {
70 70
 			return false;
71 71
 		}
72 72
 		return $this->target->satisfied();
@@ -75,10 +75,10 @@  discard block
 block discarded – undo
75 75
 	/**
76 76
 	 * {@inheritDoc}
77 77
 	 */
78
-	public function handle( $request ) {
79
-		$arguments = array_merge( [$request], $this->target->getArguments() );
80
-		return $this->executeMiddleware( $this->getMiddleware(), $request, function() use ( $arguments ) {
81
-			return call_user_func_array( [$this->handler, 'execute'], $arguments );
78
+	public function handle($request) {
79
+		$arguments = array_merge([$request], $this->target->getArguments());
80
+		return $this->executeMiddleware($this->getMiddleware(), $request, function() use ($arguments) {
81
+			return call_user_func_array([$this->handler, 'execute'], $arguments);
82 82
 		} );
83 83
 	}
84 84
 
@@ -88,21 +88,21 @@  discard block
 block discarded – undo
88 88
 	 * @param  array $options
89 89
 	 * @return ConditionInterface
90 90
 	 */
91
-	public function condition( $options ) {
92
-		if ( count( $options ) === 0 ) {
93
-			throw new Exception( 'No condition type specified.' );
91
+	public function condition($options) {
92
+		if (count($options) === 0) {
93
+			throw new Exception('No condition type specified.');
94 94
 		}
95 95
 
96 96
 		$condition_type = $options[0];
97
-		$arguments = array_slice( $options, 1 );
97
+		$arguments = array_slice($options, 1);
98 98
 
99
-		$condition_class = Framework::resolve( 'framework.routing.conditions.' . $condition_type );
100
-		if ( $condition_class === null ) {
101
-			throw new Exception( 'Unknown condition type specified: ' . $condition_type );
99
+		$condition_class = Framework::resolve('framework.routing.conditions.' . $condition_type);
100
+		if ($condition_class === null) {
101
+			throw new Exception('Unknown condition type specified: ' . $condition_type);
102 102
 		}
103 103
 
104
-		$reflection = new ReflectionClass( $condition_class );
105
-		$condition = $reflection->newInstanceArgs( $arguments );
104
+		$reflection = new ReflectionClass($condition_class);
105
+		$condition = $reflection->newInstanceArgs($arguments);
106 106
 		return $condition;
107 107
 	}
108 108
 }
Please login to merge, or discard this patch.
src/Routing/Conditions/Custom.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,16 +26,16 @@
 block discarded – undo
26 26
 	 * @param callable $callable
27 27
 	 * @param mixed    ...$arguments
28 28
 	 */
29
-	public function __construct( $callable ) {
29
+	public function __construct($callable) {
30 30
 		$this->callable = $callable;
31
-		$this->arguments = array_slice( func_get_args(), 1 );
31
+		$this->arguments = array_slice(func_get_args(), 1);
32 32
 	}
33 33
 
34 34
 	/**
35 35
 	 * {@inheritDoc}
36 36
 	 */
37 37
 	public function satisfied() {
38
-		return call_user_func_array( $this->callable, $this->arguments );
38
+		return call_user_func_array($this->callable, $this->arguments);
39 39
 	}
40 40
 
41 41
 	/**
Please login to merge, or discard this patch.
src/Routing/Middleware/HasMiddlewareTrait.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -23,12 +23,12 @@  discard block
 block discarded – undo
23 23
 	 * @param  mixed   $middleware
24 24
 	 * @return boolean
25 25
 	 */
26
-	protected function isMiddleware( $middleware ) {
27
-		if ( is_callable( $middleware ) ) {
26
+	protected function isMiddleware($middleware) {
27
+		if (is_callable($middleware)) {
28 28
 			return true;
29 29
 		}
30 30
 		
31
-		if ( is_a( $middleware, MiddlewareInterface::class, true ) ) {
31
+		if (is_a($middleware, MiddlewareInterface::class, true)) {
32 32
 			return true;
33 33
 		}
34 34
 
@@ -50,16 +50,16 @@  discard block
 block discarded – undo
50 50
 	 * @param  string|callable|\CarbonFramework\Routing\Middleware\MiddlewareInterface|array $middleware
51 51
 	 * @return object
52 52
 	 */
53
-	public function addMiddleware( $middleware ) {
54
-		$middleware = is_array( $middleware ) ? $middleware : [$middleware];
53
+	public function addMiddleware($middleware) {
54
+		$middleware = is_array($middleware) ? $middleware : [$middleware];
55 55
 
56
-		foreach ( $middleware as $item ) {
57
-			if ( ! $this->isMiddleware( $item ) ) {
58
-				throw new Exception( 'Passed middleware must be a callable or the name of a class which implements the ' . MiddlewareInterface::class . ' interface.' );
56
+		foreach ($middleware as $item) {
57
+			if ( ! $this->isMiddleware($item)) {
58
+				throw new Exception('Passed middleware must be a callable or the name of a class which implements the ' . MiddlewareInterface::class . ' interface.');
59 59
 			}
60 60
 		}
61 61
 
62
-		$this->middleware = array_merge( $this->getMiddleware(), $middleware );
62
+		$this->middleware = array_merge($this->getMiddleware(), $middleware);
63 63
 		return $this;
64 64
 	}
65 65
 
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 	 * @param  string|callable|\CarbonFramework\Routing\Middleware\MiddlewareInterface|array $middleware
70 70
 	 * @return object
71 71
 	 */
72
-	public function add( $middleware ) {
73
-		return $this->addMiddleware( $middleware );
72
+	public function add($middleware) {
73
+		return $this->addMiddleware($middleware);
74 74
 	}
75 75
 
76 76
 	/**
@@ -81,22 +81,22 @@  discard block
 block discarded – undo
81 81
 	 * @param  Closure                                                   $next
82 82
 	 * @return ResponseInterface
83 83
 	 */
84
-	public function executeMiddleware( $middleware, $request, Closure $next ) {
85
-		$top_middleware = array_pop( $middleware );
84
+	public function executeMiddleware($middleware, $request, Closure $next) {
85
+		$top_middleware = array_pop($middleware);
86 86
 
87
-		if ( $top_middleware === null ) {
88
-			return $next( $request );
87
+		if ($top_middleware === null) {
88
+			return $next($request);
89 89
 		}
90 90
 
91
-		$top_middleware_next = function( $request ) use ( $middleware, $next ) {
92
-			return $this->executeMiddleware( $middleware, $request, $next );
91
+		$top_middleware_next = function($request) use ($middleware, $next) {
92
+			return $this->executeMiddleware($middleware, $request, $next);
93 93
 		};
94 94
 
95
-		if ( is_callable( $top_middleware ) ) {
96
-			return call_user_func( $top_middleware, $request, $top_middleware_next );
95
+		if (is_callable($top_middleware)) {
96
+			return call_user_func($top_middleware, $request, $top_middleware_next);
97 97
 		}
98 98
 
99 99
 		$instance = new $top_middleware();
100
-		return $instance->handle( $request, $top_middleware_next );
100
+		return $instance->handle($request, $top_middleware_next);
101 101
 	}
102 102
 }
Please login to merge, or discard this patch.
src/Flash/Flash.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -26,12 +26,12 @@  discard block
 block discarded – undo
26 26
 	 * 
27 27
 	 * @param array|\ArrayAccess $storage
28 28
 	 */
29
-	public function __construct( &$storage ) {
30
-		if ( $this->isValidStorage( $storage ) ) {
31
-			if ( ! isset( $storage[ $this->storage_key ] ) ) {
32
-				$storage[ $this->storage_key ] = [];
29
+	public function __construct(&$storage) {
30
+		if ($this->isValidStorage($storage)) {
31
+			if ( ! isset($storage[$this->storage_key])) {
32
+				$storage[$this->storage_key] = [];
33 33
 			}
34
-			$this->storage = &$storage[ $this->storage_key ];
34
+			$this->storage = &$storage[$this->storage_key];
35 35
 		}
36 36
 	}
37 37
 
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 * @param  mixed   $storage
42 42
 	 * @return boolean
43 43
 	 */
44
-	protected function isValidStorage( $storage ) {
44
+	protected function isValidStorage($storage) {
45 45
 		return $storage !== null;
46 46
 	}
47 47
 
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 	 * @return null
53 53
 	 */
54 54
 	protected function validateStorage() {
55
-		if ( ! $this->isValidStorage( $this->storage ) ) {
56
-			throw new Exception( 'Attempted to use Flash without an active session. Did you forget to call session_start()?' );
55
+		if ( ! $this->isValidStorage($this->storage)) {
56
+			throw new Exception('Attempted to use Flash without an active session. Did you forget to call session_start()?');
57 57
 		}
58 58
 	}
59 59
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 * @return boolean
64 64
 	 */
65 65
 	public function enabled() {
66
-		return $this->isValidStorage( $this->storage );
66
+		return $this->isValidStorage($this->storage);
67 67
 	}
68 68
 
69 69
 	/**
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 	 * @param  string|null $key
73 73
 	 * @return array|\ArrayAccess
74 74
 	 */
75
-	public function get( $key = null ) {
75
+	public function get($key = null) {
76 76
 		$this->validateStorage();
77 77
 
78
-		$items = $this->peek( $key );
79
-		$this->clear( $key );
78
+		$items = $this->peek($key);
79
+		$this->clear($key);
80 80
 		return $items;
81 81
 	}
82 82
 
@@ -86,15 +86,15 @@  discard block
 block discarded – undo
86 86
 	 * @param  string|null $key
87 87
 	 * @return array|\ArrayAccess
88 88
 	 */
89
-	public function peek( $key = null ) {
89
+	public function peek($key = null) {
90 90
 		$this->validateStorage();
91 91
 		
92
-		if ( $key === null ) {
92
+		if ($key === null) {
93 93
 			return $this->storage;
94 94
 		}
95 95
 		
96
-		if ( isset( $this->storage[ $key ] ) ) {
97
-			return $this->storage[ $key ];
96
+		if (isset($this->storage[$key])) {
97
+			return $this->storage[$key];
98 98
 		}
99 99
 
100 100
 		return [];
@@ -106,18 +106,18 @@  discard block
 block discarded – undo
106 106
 	 * @param string $key
107 107
 	 * @param mixed  $new_items
108 108
 	 */
109
-	public function add( $key, $new_items ) {
109
+	public function add($key, $new_items) {
110 110
 		$this->validateStorage();
111 111
 		
112
-		$new_items = is_array( $new_items ) ? $new_items : [$new_items];
112
+		$new_items = is_array($new_items) ? $new_items : [$new_items];
113 113
 
114
-		$items = (array) $this->peek( $key );
115
-		$items = array_merge( $items, $new_items );
114
+		$items = (array) $this->peek($key);
115
+		$items = array_merge($items, $new_items);
116 116
 		
117
-		if ( $key === null ) {
117
+		if ($key === null) {
118 118
 			$this->storage = $items;
119 119
 		} else {
120
-			$this->storage[ $key ] = $items;
120
+			$this->storage[$key] = $items;
121 121
 		}
122 122
 	}
123 123
 
@@ -127,13 +127,13 @@  discard block
 block discarded – undo
127 127
 	 * @param  string|null $key
128 128
 	 * @return null
129 129
 	 */
130
-	public function clear( $key = null ) {
130
+	public function clear($key = null) {
131 131
 		$this->validateStorage();
132 132
 		
133
-		if ( $key === null ) {
133
+		if ($key === null) {
134 134
 			$this->storage = [];
135 135
 		} else {
136
-			$this->storage[ $key ] = [];
136
+			$this->storage[$key] = [];
137 137
 		}
138 138
 	}
139 139
 }
140 140
\ No newline at end of file
Please login to merge, or discard this patch.
src/Support/Arr.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     {
49 49
         $results = [];
50 50
         foreach ($array as $values) {
51
-            if (! is_array($values)) {
51
+            if ( ! is_array($values)) {
52 52
                 continue;
53 53
             }
54 54
             $results = array_merge($results, $values);
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
 
81 81
         foreach ($array as $key => $value) {
82 82
             if (is_array($value) && ! empty($value)) {
83
-                $results = array_merge($results, static::dot($value, $prepend.$key.'.'));
83
+                $results = array_merge($results, static::dot($value, $prepend . $key . '.'));
84 84
             } else {
85
-                $results[$prepend.$key] = $value;
85
+                $results[$prepend . $key] = $value;
86 86
             }
87 87
         }
88 88
 
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
      */
220 220
     public static function get($array, $key, $default = null)
221 221
     {
222
-        if (! static::accessible($array)) {
222
+        if ( ! static::accessible($array)) {
223 223
             return $default;
224 224
         }
225 225
 
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 
258 258
         $keys = (array) $keys;
259 259
 
260
-        if (! $array) {
260
+        if ( ! $array) {
261 261
             return false;
262 262
         }
263 263
 
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
             // If the key doesn't exist at this depth, we will just create an empty array
420 420
             // to hold the next value, allowing us to create the arrays to hold final
421 421
             // values at the correct depth. Then we'll keep digging into the array.
422
-            if (! isset($array[$key]) || ! is_array($array[$key])) {
422
+            if ( ! isset($array[$key]) || ! is_array($array[$key])) {
423 423
                 $array[$key] = [];
424 424
             }
425 425
 
@@ -481,9 +481,9 @@  discard block
 block discarded – undo
481 481
             return $target;
482 482
         }
483 483
         $key = is_array($key) ? $key : explode('.', $key);
484
-        while (! is_null($segment = array_shift($key))) {
484
+        while ( ! is_null($segment = array_shift($key))) {
485 485
             if ($segment === '*') {
486
-                if (! is_array($target)) {
486
+                if ( ! is_array($target)) {
487 487
                     return $default;
488 488
                 }
489 489
                 $result = static::pluck($target, $key);
Please login to merge, or discard this patch.
src/Routing/Handler.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
 	 * 
23 23
 	 * @param string|Closure $handler
24 24
 	 */
25
-	public function __construct( $handler ) {
26
-		$this->set( $handler );
25
+	public function __construct($handler) {
26
+		$this->set($handler);
27 27
 	}
28 28
 
29 29
 	/**
@@ -32,15 +32,15 @@  discard block
 block discarded – undo
32 32
 	 * @param  string|Closure $handler
33 33
 	 * @return callable|array|null
34 34
 	 */
35
-	protected function parse( $handler ) {
36
-		if ( $handler instanceof Closure ) {
35
+	protected function parse($handler) {
36
+		if ($handler instanceof Closure) {
37 37
 			return $handler;
38 38
 		}
39 39
 
40
-		if ( is_string( $handler ) )  {
41
-			$handlerPieces = preg_split( '/@|::/', $handler, 2 );
42
-			if ( count( $handlerPieces ) === 1 ) {
43
-				if ( is_callable( $handlerPieces[0] ) ) {
40
+		if (is_string($handler)) {
41
+			$handlerPieces = preg_split('/@|::/', $handler, 2);
42
+			if (count($handlerPieces) === 1) {
43
+				if (is_callable($handlerPieces[0])) {
44 44
 					return $handlerPieces[0];
45 45
 				} else {
46 46
 					return null;
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
 	 * @param  string|Closure $new_handler
63 63
 	 * @return null
64 64
 	 */
65
-	public function set( $new_handler ) {
66
-		$handler = $this->parse( $new_handler );
65
+	public function set($new_handler) {
66
+		$handler = $this->parse($new_handler);
67 67
 
68
-		if ( $handler === null ) {
69
-			throw new Exception( 'No or invalid handler provided.' );
68
+		if ($handler === null) {
69
+			throw new Exception('No or invalid handler provided.');
70 70
 		}
71 71
 
72 72
 		$this->handler = $handler;
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	public function execute() {
81 81
 		$arguments = func_get_args();
82
-		if ( is_callable( $this->handler ) ) {
83
-			return call_user_func_array( $this->handler, $arguments );
82
+		if (is_callable($this->handler)) {
83
+			return call_user_func_array($this->handler, $arguments);
84 84
 		}
85 85
 
86 86
 		$class = $this->handler['class'];
87 87
 		$method = $this->handler['method'];
88 88
 
89
-		$controller = Framework::instantiate( $class );
90
-		return call_user_func_array( [$controller, $method], $arguments );
89
+		$controller = Framework::instantiate($class);
90
+		return call_user_func_array([$controller, $method], $arguments);
91 91
 	}
92 92
 }
Please login to merge, or discard this patch.