Completed
Push — master ( 9eb8da...393642 )
by
unknown
01:34
created
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
 				}
46 46
 				return null;
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 	 * @param  string|Closure $new_handler
61 61
 	 * @return null
62 62
 	 */
63
-	public function set( $new_handler ) {
64
-		$handler = $this->parse( $new_handler );
63
+	public function set($new_handler) {
64
+		$handler = $this->parse($new_handler);
65 65
 
66
-		if ( $handler === null ) {
67
-			throw new Exception( 'No or invalid handler provided.' );
66
+		if ($handler === null) {
67
+			throw new Exception('No or invalid handler provided.');
68 68
 		}
69 69
 
70 70
 		$this->handler = $handler;
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
77 77
 	 */
78 78
 	public function execute() {
79 79
 		$arguments = func_get_args();
80
-		if ( is_callable( $this->handler ) ) {
81
-			return call_user_func_array( $this->handler, $arguments );
80
+		if (is_callable($this->handler)) {
81
+			return call_user_func_array($this->handler, $arguments);
82 82
 		}
83 83
 
84 84
 		$class = $this->handler['class'];
85 85
 		$method = $this->handler['method'];
86 86
 
87
-		$controller = Framework::instantiate( $class );
88
-		return call_user_func_array( [$controller, $method], $arguments );
87
+		$controller = Framework::instantiate($class);
88
+		return call_user_func_array([$controller, $method], $arguments);
89 89
 	}
90 90
 }
Please login to merge, or discard this patch.
src/Routing/Conditions/PostSlug.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,22 +20,22 @@
 block discarded – undo
20 20
 	 * 
21 21
 	 * @param string $post_slug
22 22
 	 */
23
-	public function __construct( $post_slug ) {
23
+	public function __construct($post_slug) {
24 24
 		$this->post_slug = $post_slug;
25 25
 	}
26 26
 
27 27
 	/**
28 28
 	 * {@inheritDoc}
29 29
 	 */
30
-	public function satisfied( Request $request ) {
30
+	public function satisfied(Request $request) {
31 31
 		$post = get_post();
32
-		return ( $post && $this->post_slug === $post->post_name );
32
+		return ($post && $this->post_slug === $post->post_name);
33 33
 	}
34 34
 
35 35
 	/**
36 36
 	 * {@inheritDoc}
37 37
 	 */
38
-	public function getArguments( Request $request ) {
38
+	public function getArguments(Request $request) {
39 39
 		return [$this->post_slug];
40 40
 	}
41 41
 }
Please login to merge, or discard this patch.
src/Routing/Conditions/PostTemplate.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,24 +28,24 @@
 block discarded – undo
28 28
 	 * @param string          $post_template
29 29
 	 * @param string|string[] $post_types
30 30
 	 */
31
-	public function __construct( $post_template, $post_types = [] ) {
31
+	public function __construct($post_template, $post_types = []) {
32 32
 		$this->post_template = $post_template;
33
-		$this->post_types = is_array( $post_types ) ? $post_types : [$post_types];
33
+		$this->post_types = is_array($post_types) ? $post_types : [$post_types];
34 34
 	}
35 35
 
36 36
 	/**
37 37
 	 * {@inheritDoc}
38 38
 	 */
39
-	public function satisfied( Request $request ) {
40
-		$template = get_post_meta( get_the_ID(), '_wp_page_template', true );
39
+	public function satisfied(Request $request) {
40
+		$template = get_post_meta(get_the_ID(), '_wp_page_template', true);
41 41
 		$template = $template ? $template : 'default';
42
-		return ( is_singular( $this->post_types ) && $this->post_template === $template );
42
+		return (is_singular($this->post_types) && $this->post_template === $template);
43 43
 	}
44 44
 
45 45
 	/**
46 46
 	 * {@inheritDoc}
47 47
 	 */
48
-	public function getArguments( Request $request ) {
48
+	public function getArguments(Request $request) {
49 49
 		return [$this->post_template, $this->post_types];
50 50
 	}
51 51
 }
Please login to merge, or discard this patch.
src/Routing/Conditions/Custom.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,22 +28,22 @@
 block discarded – undo
28 28
 	 * @param callable $callable
29 29
 	 * @param mixed    ...$arguments
30 30
 	 */
31
-	public function __construct( $callable ) {
31
+	public function __construct($callable) {
32 32
 		$this->callable = $callable;
33
-		$this->arguments = array_slice( func_get_args(), 1 );
33
+		$this->arguments = array_slice(func_get_args(), 1);
34 34
 	}
35 35
 
36 36
 	/**
37 37
 	 * {@inheritDoc}
38 38
 	 */
39
-	public function satisfied( Request $request ) {
40
-		return call_user_func_array( $this->callable, $this->arguments );
39
+	public function satisfied(Request $request) {
40
+		return call_user_func_array($this->callable, $this->arguments);
41 41
 	}
42 42
 
43 43
 	/**
44 44
 	 * {@inheritDoc}
45 45
 	 */
46
-	public function getArguments( Request $request ) {
46
+	public function getArguments(Request $request) {
47 47
 		return $this->arguments;
48 48
 	}
49 49
 }
Please login to merge, or discard this patch.
src/Routing/Conditions/PostId.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,21 +20,21 @@
 block discarded – undo
20 20
 	 * 
21 21
 	 * @param string $post_id
22 22
 	 */
23
-	public function __construct( $post_id ) {
23
+	public function __construct($post_id) {
24 24
 		$this->post_id = $post_id;
25 25
 	}
26 26
 
27 27
 	/**
28 28
 	 * {@inheritDoc}
29 29
 	 */
30
-	public function satisfied( Request $request ) {
30
+	public function satisfied(Request $request) {
31 31
 		return $this->post_id === get_the_ID();
32 32
 	}
33 33
 
34 34
 	/**
35 35
 	 * {@inheritDoc}
36 36
 	 */
37
-	public function getArguments( Request $request ) {
37
+	public function getArguments(Request $request) {
38 38
 		return [$this->post_id];
39 39
 	}
40 40
 }
Please login to merge, or discard this patch.
src/Routing/Conditions/PostType.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,21 +20,21 @@
 block discarded – undo
20 20
 	 * 
21 21
 	 * @param string $post_type
22 22
 	 */
23
-	public function __construct( $post_type ) {
23
+	public function __construct($post_type) {
24 24
 		$this->post_type = $post_type;
25 25
 	}
26 26
 
27 27
 	/**
28 28
 	 * {@inheritDoc}
29 29
 	 */
30
-	public function satisfied( Request $request ) {
30
+	public function satisfied(Request $request) {
31 31
 		return $this->post_type === get_post_type();
32 32
 	}
33 33
 
34 34
 	/**
35 35
 	 * {@inheritDoc}
36 36
 	 */
37
-	public function getArguments( Request $request ) {
37
+	public function getArguments(Request $request) {
38 38
 		return [$this->post_type];
39 39
 	}
40 40
 }
Please login to merge, or discard this patch.
src/Routing/Conditions/ConditionInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	 * @param  Request $request
15 15
 	 * @return boolean
16 16
 	 */
17
-	public function satisfied( Request $request );
17
+	public function satisfied(Request $request);
18 18
 
19 19
 	/**
20 20
 	 * Return an array of arguments for use in request
@@ -22,5 +22,5 @@  discard block
 block discarded – undo
22 22
 	 * @param  Request $request
23 23
 	 * @return array
24 24
 	 */
25
-	public function getArguments( Request $request );
25
+	public function getArguments(Request $request);
26 26
 }
Please login to merge, or discard this patch.
src/Routing/RouteInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	 * @param  Request $request
16 16
 	 * @return boolean
17 17
 	 */
18
-	public function satisfied( Request $request );
18
+	public function satisfied(Request $request);
19 19
 
20 20
 	/**
21 21
 	 * Return a response for the given request
@@ -23,5 +23,5 @@  discard block
 block discarded – undo
23 23
 	 * @param  Request                             $request
24 24
 	 * @return \Psr\Http\Message\ResponseInterface
25 25
 	 */
26
-	public function handle( Request $request );
26
+	public function handle(Request $request);
27 27
 }
Please login to merge, or discard this patch.
src/Routing/RouteGroup.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -31,18 +31,18 @@  discard block
 block discarded – undo
31 31
 	 * @param string|ConditionInterface $target
32 32
 	 * @param Closure                   $callable
33 33
 	 */
34
-	public function __construct( $target, Closure $callable ) {
35
-		if ( is_string( $target ) ) {
36
-			$target = new UrlCondition( $target );
34
+	public function __construct($target, Closure $callable) {
35
+		if (is_string($target)) {
36
+			$target = new UrlCondition($target);
37 37
 		}
38 38
 
39
-		if ( ! is_a( $target, UrlCondition::class ) ) {
40
-			throw new Exception( 'Route groups can only use route strings.' );
39
+		if ( ! is_a($target, UrlCondition::class)) {
40
+			throw new Exception('Route groups can only use route strings.');
41 41
 		}
42 42
 
43 43
 		$this->target = $target;
44 44
 
45
-		$callable( $this );
45
+		$callable($this);
46 46
 	}
47 47
 
48 48
 	/**
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
 	 * 
51 51
 	 * @return RouteInterface|null
52 52
 	 */
53
-	protected function getSatisfiedRoute( Request $request ) {
53
+	protected function getSatisfiedRoute(Request $request) {
54 54
 		$routes = $this->getRoutes();
55
-		foreach ( $routes as $route ) {
56
-			if ( $route->satisfied( $request ) ) {
55
+		foreach ($routes as $route) {
56
+			if ($route->satisfied($request)) {
57 57
 				return $route;
58 58
 			}
59 59
 		}
@@ -63,45 +63,45 @@  discard block
 block discarded – undo
63 63
 	/**
64 64
 	 * {@inheritDoc}
65 65
 	 */
66
-	public function satisfied( Request $request ) {
67
-		$route = $this->getSatisfiedRoute( $request );
66
+	public function satisfied(Request $request) {
67
+		$route = $this->getSatisfiedRoute($request);
68 68
 		return $route !== null;
69 69
 	}
70 70
 
71 71
 	/**
72 72
 	 * {@inheritDoc}
73 73
 	 */
74
-	public function handle( Request $request ) {
75
-		$route = $this->getSatisfiedRoute( $request );
76
-		return $route ? $route->handle( $request ) : null;
74
+	public function handle(Request $request) {
75
+		$route = $this->getSatisfiedRoute($request);
76
+		return $route ? $route->handle($request) : null;
77 77
 	}
78 78
 
79 79
 	/**
80 80
 	 * {@inheritDoc}
81 81
 	 */
82
-	public function route( $methods, $target, $handler ) {
83
-		if ( is_string( $target ) ) {
84
-			$target = new UrlCondition( $target );
82
+	public function route($methods, $target, $handler) {
83
+		if (is_string($target)) {
84
+			$target = new UrlCondition($target);
85 85
 		}
86 86
 
87
-		if ( ! is_a( $target, UrlCondition::class ) ) {
88
-			throw new Exception( 'Routes inside route groups can only use route strings.' );
87
+		if ( ! is_a($target, UrlCondition::class)) {
88
+			throw new Exception('Routes inside route groups can only use route strings.');
89 89
 		}
90 90
 
91
-		$target = $this->target->concatenate( $target );
92
-		return $this->traitRoute( $methods, $target, $handler );
91
+		$target = $this->target->concatenate($target);
92
+		return $this->traitRoute($methods, $target, $handler);
93 93
 	}
94 94
 
95 95
 	/**
96 96
 	 * {@inheritDoc}
97 97
 	 */
98
-	public function addMiddleware( $middleware ) {
98
+	public function addMiddleware($middleware) {
99 99
 		$routes = $this->getRoutes();
100 100
 
101
-		foreach ( $routes as $route ) {
102
-			$route->addMiddleware( $middleware );
101
+		foreach ($routes as $route) {
102
+			$route->addMiddleware($middleware);
103 103
 		}
104 104
 		
105
-		return $this->traitAddMiddleware( $middleware );
105
+		return $this->traitAddMiddleware($middleware);
106 106
 	}
107 107
 }
Please login to merge, or discard this patch.