Passed
Branch master (158c7e)
by htmlBurger
02:35
created
src/ServiceProviders/ServiceProviderInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	 * @param  \Pimple\Container $container
13 13
 	 * @return null
14 14
 	 */
15
-	public function register( $container );
15
+	public function register($container);
16 16
 
17 17
 	/**
18 18
 	 * Bootstrap any services if needed
@@ -20,5 +20,5 @@  discard block
 block discarded – undo
20 20
 	 * @param  \Pimple\Container $container
21 21
 	 * @return null
22 22
 	 */
23
-	public function boot( $container );
23
+	public function boot($container);
24 24
 }
25 25
\ No newline at end of file
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  any     $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
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
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 any|array $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 = $this->peek( $key );
115
-		$items = array_merge( $items, $new_items );
114
+		$items = $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/Routing/RouteInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,5 +21,5 @@
 block discarded – undo
21 21
 	 * @param  \CarbonFramework\Request            $request
22 22
 	 * @return \Psr\Http\Message\ResponseInterface
23 23
 	 */
24
-	public function handle( $request );
24
+	public function handle($request);
25 25
 }
Please login to merge, or discard this patch.
src/Routing/Middleware/MiddlewareInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,5 +14,5 @@
 block discarded – undo
14 14
 	 * @param \CarbonFramework\Request $request
15 15
 	 * @param  Closure                 $next
16 16
 	 */
17
-	public function handle( $request, Closure $next );
17
+	public function handle($request, Closure $next);
18 18
 }
Please login to merge, or discard this patch.
src/Routing/Middleware/HasMiddlewareInterface.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 * @param  string|callable|\CarbonFramework\Routing\Middleware\MiddlewareInterface|array $middleware
23 23
 	 * @return object
24 24
 	 */
25
-	public function addMiddleware( $middleware );
25
+	public function addMiddleware($middleware);
26 26
 
27 27
 	/**
28 28
 	 * Alias for addMiddleware
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 * @param  string|callable|\CarbonFramework\Routing\Middleware\MiddlewareInterface|array $middleware
31 31
 	 * @return object
32 32
 	 */
33
-	public function add( $middleware );
33
+	public function add($middleware);
34 34
 
35 35
 	/**
36 36
 	 * Execute an array of middleware recursively (last in, first out)
@@ -40,5 +40,5 @@  discard block
 block discarded – undo
40 40
 	 * @param  Closure                                                   $next
41 41
 	 * @return ResponseInterface
42 42
 	 */
43
-	public function executeMiddleware( $middleware, $request, Closure $next );
43
+	public function executeMiddleware($middleware, $request, Closure $next);
44 44
 }
Please login to merge, or discard this patch.
src/Routing/Middleware/OldInput.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@
 block discarded – undo
14 14
 	/**
15 15
 	 * {@inheritDoc}
16 16
 	 */
17
-	public function handle( $request, Closure $next ) {
18
-		$response = $next( $request );
17
+	public function handle($request, Closure $next) {
18
+		$response = $next($request);
19 19
 
20
-		if ( Flash::enabled() ) {
21
-			Flash::clear( OldInputService::getFlashKey() );
20
+		if (Flash::enabled()) {
21
+			Flash::clear(OldInputService::getFlashKey());
22 22
 
23
-			if ( $request->getMethod() === 'POST' ) {
24
-				Flash::add( OldInputService::getFlashKey(), $request->post() );
23
+			if ($request->getMethod() === 'POST') {
24
+				Flash::add(OldInputService::getFlashKey(), $request->post());
25 25
 			}
26 26
 		}
27 27
 		
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  any     $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,17 +50,17 @@  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 ) ) {
56
+		foreach ($middleware as $item) {
57
+			if ( ! $this->isMiddleware($item)) {
58 58
 				var_dump($item);
59
-				throw new Exception( 'Passed middleware must be a callable or the name of a class which implements the ' . MiddlewareInterface::class . ' interface.' );
59
+				throw new Exception('Passed middleware must be a callable or the name of a class which implements the ' . MiddlewareInterface::class . ' interface.');
60 60
 			}
61 61
 		}
62 62
 
63
-		$this->middleware = array_merge( $this->getMiddleware(), $middleware );
63
+		$this->middleware = array_merge($this->getMiddleware(), $middleware);
64 64
 		return $this;
65 65
 	}
66 66
 
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
 	 * @param  string|callable|\CarbonFramework\Routing\Middleware\MiddlewareInterface|array $middleware
71 71
 	 * @return object
72 72
 	 */
73
-	public function add( $middleware ) {
74
-		return $this->addMiddleware( $middleware );
73
+	public function add($middleware) {
74
+		return $this->addMiddleware($middleware);
75 75
 	}
76 76
 
77 77
 	/**
@@ -82,22 +82,22 @@  discard block
 block discarded – undo
82 82
 	 * @param  Closure                                                   $next
83 83
 	 * @return ResponseInterface
84 84
 	 */
85
-	public function executeMiddleware( $middleware, $request, Closure $next ) {
86
-		$top_middleware = array_pop( $middleware );
85
+	public function executeMiddleware($middleware, $request, Closure $next) {
86
+		$top_middleware = array_pop($middleware);
87 87
 
88
-		if ( $top_middleware === null ) {
89
-			return $next( $request );
88
+		if ($top_middleware === null) {
89
+			return $next($request);
90 90
 		}
91 91
 
92
-		$top_middleware_next = function( $request ) use ( $middleware, $next ) {
93
-			return $this->executeMiddleware( $middleware, $request, $next );
92
+		$top_middleware_next = function($request) use ($middleware, $next) {
93
+			return $this->executeMiddleware($middleware, $request, $next);
94 94
 		};
95 95
 
96
-		if ( is_callable( $top_middleware ) ) {
97
-			return call_user_func( $top_middleware, $request, $top_middleware_next );
96
+		if (is_callable($top_middleware)) {
97
+			return call_user_func($top_middleware, $request, $top_middleware_next);
98 98
 		}
99 99
 
100 100
 		$instance = new $top_middleware();
101
-		return $instance->handle( $request, $top_middleware_next );
101
+		return $instance->handle($request, $top_middleware_next);
102 102
 	}
103 103
 }
Please login to merge, or discard this patch.
src/Routing/HasRoutesTrait.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 * @param RouteInterface  $route
31 31
 	 * @return RouteInterface
32 32
 	 */
33
-	public function addRoute( $route ) {
33
+	public function addRoute($route) {
34 34
 		$this->routes[] = $route;
35 35
 		return $route;
36 36
 	}
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
 	 * @param  string|Closure $handler
44 44
 	 * @return RouteInterface
45 45
 	 */
46
-	public function route( $methods, $target, $handler ) {
47
-		$route = new Route( $methods, $target, $handler );
48
-		return $this->addRoute( $route );
46
+	public function route($methods, $target, $handler) {
47
+		$route = new Route($methods, $target, $handler);
48
+		return $this->addRoute($route);
49 49
 	}
50 50
 
51 51
 	/**
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
 	 * @param  Closure        $callable
56 56
 	 * @return RouteInterface
57 57
 	 */
58
-	public function group( $target, Closure $callable ) {
59
-		$routeGroup = new RouteGroup( $target, $callable );
60
-		return $this->addRoute( $routeGroup );
58
+	public function group($target, Closure $callable) {
59
+		$routeGroup = new RouteGroup($target, $callable);
60
+		return $this->addRoute($routeGroup);
61 61
 	}
62 62
 
63 63
 	/**
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
 	 * @param  string|Closure $handler
68 68
 	 * @return RouteInterface
69 69
 	 */
70
-	public function get( $target, $handler ) {
71
-		return $this->route( ['GET', 'HEAD'], $target, $handler );
70
+	public function get($target, $handler) {
71
+		return $this->route(['GET', 'HEAD'], $target, $handler);
72 72
 	}
73 73
 
74 74
 	/**
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 	 * @param  string|Closure $handler
79 79
 	 * @return RouteInterface
80 80
 	 */
81
-	public function post( $target, $handler ) {
82
-		return $this->route( ['POST'], $target, $handler );
81
+	public function post($target, $handler) {
82
+		return $this->route(['POST'], $target, $handler);
83 83
 	}
84 84
 
85 85
 	/**
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
 	 * @param  string|Closure $handler
90 90
 	 * @return RouteInterface
91 91
 	 */
92
-	public function put( $target, $handler ) {
93
-		return $this->route( ['PUT'], $target, $handler );
92
+	public function put($target, $handler) {
93
+		return $this->route(['PUT'], $target, $handler);
94 94
 	}
95 95
 
96 96
 	/**
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 	 * @param  string|Closure $handler
101 101
 	 * @return RouteInterface
102 102
 	 */
103
-	public function patch( $target, $handler ) {
104
-		return $this->route( ['PATCH'], $target, $handler );
103
+	public function patch($target, $handler) {
104
+		return $this->route(['PATCH'], $target, $handler);
105 105
 	}
106 106
 
107 107
 	/**
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 	 * @param  string|Closure $handler
112 112
 	 * @return RouteInterface
113 113
 	 */
114
-	public function delete( $target, $handler ) {
115
-		return $this->route( ['DELETE'], $target, $handler );
114
+	public function delete($target, $handler) {
115
+		return $this->route(['DELETE'], $target, $handler);
116 116
 	}
117 117
 
118 118
 	/**
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 	 * @param  string|Closure $handler
123 123
 	 * @return RouteInterface
124 124
 	 */
125
-	public function options( $target, $handler ) {
126
-		return $this->route( ['OPTIONS'], $target, $handler );
125
+	public function options($target, $handler) {
126
+		return $this->route(['OPTIONS'], $target, $handler);
127 127
 	}
128 128
 
129 129
 	/**
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 * @param  string|Closure $handler
134 134
 	 * @return RouteInterface
135 135
 	 */
136
-	public function any( $target, $handler ) {
137
-		return $this->route( ['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'], $target, $handler );
136
+	public function any($target, $handler) {
137
+		return $this->route(['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'], $target, $handler);
138 138
 	}
139 139
 }
Please login to merge, or discard this patch.
src/Routing/Conditions/Url.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
 	 * 
43 43
 	 * @param string $url
44 44
 	 */
45
-	public function __construct( $url ) {
46
-		$url = UrlUtility::addLeadingSlash( $url );
47
-		$url = UrlUtility::addTrailingSlash( $url );
45
+	public function __construct($url) {
46
+		$url = UrlUtility::addLeadingSlash($url);
47
+		$url = UrlUtility::addTrailingSlash($url);
48 48
 		$this->url = $url;
49 49
 	}
50 50
 
@@ -52,28 +52,28 @@  discard block
 block discarded – undo
52 52
 	 * {@inheritDoc}
53 53
 	 */
54 54
 	public function satisfied() {
55
-		$validation_regex = $this->getValidationRegex( $this->getUrl() );
55
+		$validation_regex = $this->getValidationRegex($this->getUrl());
56 56
 		$url = $this->getCurrentPath();
57
-		return preg_match( $validation_regex, $url );
57
+		return preg_match($validation_regex, $url);
58 58
 	}
59 59
 
60 60
 	/**
61 61
 	 * {@inheritDoc}
62 62
 	 */
63 63
 	public function getArguments() {
64
-		$validation_regex = $this->getValidationRegex( $this->getUrl() );
64
+		$validation_regex = $this->getValidationRegex($this->getUrl());
65 65
 		$url = $this->getCurrentPath();
66 66
 		$matches = [];
67
-		$success = preg_match( $validation_regex, $url, $matches );
67
+		$success = preg_match($validation_regex, $url, $matches);
68 68
 
69
-		if ( ! $success ) {
69
+		if ( ! $success) {
70 70
 			return []; // this should not normally happen
71 71
 		}
72 72
 
73 73
 		$arguments = [];
74
-		$parameter_names = $this->getParameterNames( $this->getUrl() );
75
-		foreach ( $parameter_names as $parameter_name ) {
76
-			$arguments[] = ! empty( $matches[ $parameter_name ] ) ? $matches[ $parameter_name ] : '';
74
+		$parameter_names = $this->getParameterNames($this->getUrl());
75
+		foreach ($parameter_names as $parameter_name) {
76
+			$arguments[] = ! empty($matches[$parameter_name]) ? $matches[$parameter_name] : '';
77 77
 		}
78 78
 		
79 79
 		return $arguments;
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	 * @return string
95 95
 	 */
96 96
 	protected function getCurrentPath() {
97
-		return UrlUtility::addTrailingSlash( UrlUtility::getCurrentPath() );
97
+		return UrlUtility::addTrailingSlash(UrlUtility::getCurrentPath());
98 98
 	}
99 99
 
100 100
 	/**
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 	 * @param  Url $url
104 104
 	 * @return Url
105 105
 	 */
106
-	public function concatenate( Url $url ) {
107
-		return new static( UrlUtility::removeTrailingSlash( $this->getUrl() ) . $url->getUrl() );
106
+	public function concatenate(Url $url) {
107
+		return new static(UrlUtility::removeTrailingSlash($this->getUrl()) . $url->getUrl());
108 108
 	}
109 109
 
110 110
 	/**
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 	 * @param  string   $url
114 114
 	 * @return string[]
115 115
 	 */
116
-	protected function getParameterNames( $url ) {
116
+	protected function getParameterNames($url) {
117 117
 		$matches = [];
118
-		preg_match_all( $this->url_regex, $url, $matches );
118
+		preg_match_all($this->url_regex, $url, $matches);
119 119
 		return $matches['name'];
120 120
 	}
121 121
 
@@ -125,29 +125,29 @@  discard block
 block discarded – undo
125 125
 	 * @param  string $url
126 126
 	 * @return string
127 127
 	 */
128
-	protected function getValidationRegex( $url ) {
128
+	protected function getValidationRegex($url) {
129 129
 		$parameters = [];
130 130
 
131 131
 		// Replace all parameters with placeholders
132
-		$validation_regex = preg_replace_callback( $this->url_regex, function( $matches ) use ( &$parameters ) {
132
+		$validation_regex = preg_replace_callback($this->url_regex, function($matches) use (&$parameters) {
133 133
 			$name = $matches['name'];
134
-			$optional = ! empty( $matches['optional'] );
135
-			$regex = ! empty( $matches['regex'] ) ? $matches['regex'] : $this->parameter_regex;
134
+			$optional = ! empty($matches['optional']);
135
+			$regex = ! empty($matches['regex']) ? $matches['regex'] : $this->parameter_regex;
136 136
 			$replacement = '(?:/(?P<' . $name . '>' . $regex . '))';
137
-			if ( $optional ) {
137
+			if ($optional) {
138 138
 				$replacement .= '?';
139 139
 			}
140 140
 
141
-			$placeholder = '___placeholder_' . sha1( count( $parameters) . '_' . $replacement . '_' . uniqid() ) . '___';
142
-			$parameters[ $placeholder ] = $replacement;
141
+			$placeholder = '___placeholder_' . sha1(count($parameters) . '_' . $replacement . '_' . uniqid()) . '___';
142
+			$parameters[$placeholder] = $replacement;
143 143
 			return $placeholder;
144
-		}, $url );
144
+		}, $url);
145 145
 
146 146
 		// quote the remaining string so that it does not get evaluated as regex
147
-		$validation_regex = preg_quote( $validation_regex, '~' );
147
+		$validation_regex = preg_quote($validation_regex, '~');
148 148
 
149 149
 		// replace the placeholders with the real parameter regexes
150
-		$validation_regex = str_replace( array_keys( $parameters ), array_values( $parameters ), $validation_regex );
150
+		$validation_regex = str_replace(array_keys($parameters), array_values($parameters), $validation_regex);
151 151
 
152 152
 		// make sure that the regex matches the entire string
153 153
 		$validation_regex = '~\A' . $validation_regex . '\z~';
Please login to merge, or discard this patch.