Completed
Pull Request — master (#2)
by René
04:48 queued 02:28
created
src/Model/User.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,7 +9,6 @@
 block discarded – undo
9 9
  *
10 10
  * @package Zortje\MVC\Model
11 11
  */
12
-class User extends Entity
13
-{
12
+class User extends Entity {
14 13
 
15 14
 }
Please login to merge, or discard this patch.
src/Network/Request.php 2 patches
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -10,39 +10,39 @@
 block discarded – undo
10 10
 class Request
11 11
 {
12 12
 
13
-    /**
14
-     * @var string Full URL
15
-     */
16
-    protected $url;
17
-
18
-    /**
19
-     * @var array POST data
20
-     */
21
-    protected $post;
22
-
23
-    /**
24
-     * Get request URL path
25
-     *
26
-     * @return string URL path
27
-     */
28
-    public function getPath()
29
-    {
30
-        $path = parse_url($this->url, PHP_URL_PATH);
31
-
32
-        if ($path === false) {
33
-            $path = '';
34
-        }
35
-
36
-        return $path;
37
-    }
38
-
39
-    /**
40
-     * @param string $url  URL of the request, trailing slash are removed automatically
41
-     * @param array  $post URL post fields
42
-     */
43
-    public function __construct($url, array $post)
44
-    {
45
-        $this->url  = rtrim($url, '/');
46
-        $this->post = $post;
47
-    }
13
+	/**
14
+	 * @var string Full URL
15
+	 */
16
+	protected $url;
17
+
18
+	/**
19
+	 * @var array POST data
20
+	 */
21
+	protected $post;
22
+
23
+	/**
24
+	 * Get request URL path
25
+	 *
26
+	 * @return string URL path
27
+	 */
28
+	public function getPath()
29
+	{
30
+		$path = parse_url($this->url, PHP_URL_PATH);
31
+
32
+		if ($path === false) {
33
+			$path = '';
34
+		}
35
+
36
+		return $path;
37
+	}
38
+
39
+	/**
40
+	 * @param string $url  URL of the request, trailing slash are removed automatically
41
+	 * @param array  $post URL post fields
42
+	 */
43
+	public function __construct($url, array $post)
44
+	{
45
+		$this->url  = rtrim($url, '/');
46
+		$this->post = $post;
47
+	}
48 48
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,8 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  * @package Zortje\MVC\Network
9 9
  */
10
-class Request
11
-{
10
+class Request {
12 11
 
13 12
     /**
14 13
      * @var string Full URL
@@ -25,8 +24,7 @@  discard block
 block discarded – undo
25 24
      *
26 25
      * @return string URL path
27 26
      */
28
-    public function getPath()
29
-    {
27
+    public function getPath() {
30 28
         $path = parse_url($this->url, PHP_URL_PATH);
31 29
 
32 30
         if ($path === false) {
@@ -40,8 +38,7 @@  discard block
 block discarded – undo
40 38
      * @param string $url  URL of the request, trailing slash are removed automatically
41 39
      * @param array  $post URL post fields
42 40
      */
43
-    public function __construct($url, array $post)
44
-    {
41
+    public function __construct($url, array $post) {
45 42
         $this->url  = rtrim($url, '/');
46 43
         $this->post = $post;
47 44
     }
Please login to merge, or discard this patch.
src/Network/Response.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -10,34 +10,34 @@
 block discarded – undo
10 10
 class Response
11 11
 {
12 12
 
13
-    /**
14
-     * @var array HTTP headers
15
-     */
16
-    protected $headers = [];
13
+	/**
14
+	 * @var array HTTP headers
15
+	 */
16
+	protected $headers = [];
17 17
 
18
-    /**
19
-     * @var string Output
20
-     */
21
-    protected $output;
18
+	/**
19
+	 * @var string Output
20
+	 */
21
+	protected $output;
22 22
 
23
-    /**
24
-     * @return array
25
-     */
26
-    public function output()
27
-    {
28
-        return [
29
-            'headers' => $this->headers,
30
-            'output'  => $this->output
31
-        ];
32
-    }
23
+	/**
24
+	 * @return array
25
+	 */
26
+	public function output()
27
+	{
28
+		return [
29
+			'headers' => $this->headers,
30
+			'output'  => $this->output
31
+		];
32
+	}
33 33
 
34
-    /**
35
-     * @param array  $headers
36
-     * @param string $output
37
-     */
38
-    public function __construct($headers, $output)
39
-    {
40
-        $this->headers = $headers;
41
-        $this->output  = $output;
42
-    }
34
+	/**
35
+	 * @param array  $headers
36
+	 * @param string $output
37
+	 */
38
+	public function __construct($headers, $output)
39
+	{
40
+		$this->headers = $headers;
41
+		$this->output  = $output;
42
+	}
43 43
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,8 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  * @package Zortje\MVC\Network
9 9
  */
10
-class Response
11
-{
10
+class Response {
12 11
 
13 12
     /**
14 13
      * @var array HTTP headers
@@ -23,8 +22,7 @@  discard block
 block discarded – undo
23 22
     /**
24 23
      * @return array
25 24
      */
26
-    public function output()
27
-    {
25
+    public function output() {
28 26
         return [
29 27
             'headers' => $this->headers,
30 28
             'output'  => $this->output
@@ -35,8 +33,7 @@  discard block
 block discarded – undo
35 33
      * @param array  $headers
36 34
      * @param string $output
37 35
      */
38
-    public function __construct($headers, $output)
39
-    {
36
+    public function __construct($headers, $output) {
40 37
         $this->headers = $headers;
41 38
         $this->output  = $output;
42 39
     }
Please login to merge, or discard this patch.
src/Routing/Dispatcher.php 2 patches
Indentation   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -23,179 +23,179 @@
 block discarded – undo
23 23
 class Dispatcher
24 24
 {
25 25
 
26
-    /**
27
-     * @var Router
28
-     */
29
-    protected $router;
30
-
31
-    /**
32
-     * @var \PDO PDO
33
-     */
34
-    protected $pdo;
35
-
36
-    /**
37
-     * @var string App file path
38
-     */
39
-    protected $appPath;
40
-
41
-    /**
42
-     * @var null|User User
43
-     */
44
-    protected $user;
45
-
46
-    /**
47
-     * @var Logger
48
-     */
49
-    protected $logger;
50
-
51
-    /**
52
-     * Set logger to be used for any logging that could occure in the dispatching process
53
-     *
54
-     * @param Logger $logger
55
-     */
56
-    public function setLogger(Logger $logger)
57
-    {
58
-        $this->logger = $logger;
59
-    }
60
-
61
-    /**
62
-     * @param Request $request Request object
63
-     *
64
-     * @return Response Reponse object
65
-     *
66
-     * @throws \Exception If unexpected exception is thrown
67
-     */
68
-    public function dispatch(Request $request)
69
-    {
70
-        $controllerFactory = new ControllerFactory($this->pdo, $this->appPath, $this->user);
71
-
72
-        try {
73
-            list($controllerName, $action) = array_values($this->router->route($request->getPath()));
74
-
75
-            /**
76
-             * Validate and initialize controller
77
-             */
78
-            try {
79
-                $controller = $controllerFactory->create($controllerName);
80
-            } catch (\Exception $e) {
81
-                if ($e instanceof ControllerNonexistentException || $e instanceof ControllerInvalidSuperclassException) {
82
-                    /**
83
-                     * Log invalid superclass
84
-                     */
85
-                    if ($this->logger && $e instanceof ControllerInvalidSuperclassException) {
86
-                        $this->logger->addCritical('Controller must be an subclass of Zortje\MVC\Controller', [
87
-                            'path'       => $request->getPath(),
88
-                            'controller' => $controllerName
89
-                        ]);
90
-                    }
91
-
92
-                    /**
93
-                     * Log nonexistent
94
-                     */
95
-                    if ($this->logger && $e instanceof ControllerNonexistentException) {
96
-                        $this->logger->addCritical('Controller is nonexistent', [
97
-                            'path'       => $request->getPath(),
98
-                            'controller' => $controllerName
99
-                        ]);
100
-                    }
101
-
102
-                    $controller = $controllerFactory->create(NotFoundController::class);
103
-                    $action     = 'index';
104
-                } else {
105
-                    throw $e;
106
-                }
107
-            }
108
-        } catch (RouteNonexistentException $e) {
109
-            /**
110
-             * Log nonexistent route (404)
111
-             */
112
-            if ($this->logger) {
113
-                $this->logger->addWarning('Route not connected', [
114
-                    'path' => $request->getPath()
115
-                ]);
116
-            }
117
-
118
-            $controller = $controllerFactory->create(NotFoundController::class);
119
-            $action     = 'index';
120
-        }
121
-
122
-        /**
123
-         * Validate and set controller action
124
-         */
125
-        try {
126
-            $controller->setAction($action);
127
-        } catch (ControllerActionProtectedInsufficientAuthenticationException $e) {
128
-            /**
129
-             * Log unauthed protected controller action (403)
130
-             */
131
-            if ($this->logger) {
132
-                $this->logger->addWarning('Unauthenticated attempt to access protected action', [
133
-                    'path'       => $request->getPath(),
134
-                    'controller' => $controller->getShortName(),
135
-                    'action'     => $action
136
-                ]);
137
-            }
138
-
139
-            // @todo redirect to login page & and save what action was requested to redirect after successful login
140
-
141
-        } catch (ControllerActionPrivateInsufficientAuthenticationException $e) {
142
-            /**
143
-             * Log unauthed private controller action (403)
144
-             */
145
-            if ($this->logger) {
146
-                $this->logger->addWarning('Unauthenticated attempt to access private action', [
147
-                    'path'       => $request->getPath(),
148
-                    'controller' => $controller->getShortName(),
149
-                    'action'     => $action
150
-                ]);
151
-            }
152
-
153
-            $controller = $controllerFactory->create(NotFoundController::class);
154
-        } catch (ControllerActionNonexistentException $e) {
155
-            /**
156
-             * Log nonexistent controller action
157
-             */
158
-            if ($this->logger) {
159
-                $this->logger->addCritical('Controller action is nonexistent', [
160
-                    'path'       => $request->getPath(),
161
-                    'controller' => $controller->getShortName(),
162
-                    'action'     => $action
163
-                ]);
164
-            }
165
-
166
-            $controller = $controllerFactory->create(NotFoundController::class);
167
-        }
168
-
169
-        /**
170
-         * Create response from controller action headers and output
171
-         */
172
-        list($headers, $output) = array_values($controller->callAction());
173
-
174
-        /**
175
-         * Performance logging
176
-         */
177
-        if ($this->logger) {
178
-            $this->logger->addDebug(vsprintf('Dispatched request in %s ms',
179
-                number_format((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']) * 1000, 2)), [
180
-                'path' => $request->getPath()
181
-            ]);
182
-        }
183
-
184
-        return new Response($headers, $output);
185
-    }
186
-
187
-    /**
188
-     * @param Router    $router
189
-     * @param \PDO      $pdo
190
-     * @param string    $appPath
191
-     * @param null|User $user
192
-     */
193
-    public function __construct(Router $router, \PDO $pdo, $appPath, User $user = null)
194
-    {
195
-        $this->router  = $router;
196
-        $this->pdo     = $pdo;
197
-        $this->appPath = $appPath;
198
-        $this->user    = $user;
199
-    }
26
+	/**
27
+	 * @var Router
28
+	 */
29
+	protected $router;
30
+
31
+	/**
32
+	 * @var \PDO PDO
33
+	 */
34
+	protected $pdo;
35
+
36
+	/**
37
+	 * @var string App file path
38
+	 */
39
+	protected $appPath;
40
+
41
+	/**
42
+	 * @var null|User User
43
+	 */
44
+	protected $user;
45
+
46
+	/**
47
+	 * @var Logger
48
+	 */
49
+	protected $logger;
50
+
51
+	/**
52
+	 * Set logger to be used for any logging that could occure in the dispatching process
53
+	 *
54
+	 * @param Logger $logger
55
+	 */
56
+	public function setLogger(Logger $logger)
57
+	{
58
+		$this->logger = $logger;
59
+	}
60
+
61
+	/**
62
+	 * @param Request $request Request object
63
+	 *
64
+	 * @return Response Reponse object
65
+	 *
66
+	 * @throws \Exception If unexpected exception is thrown
67
+	 */
68
+	public function dispatch(Request $request)
69
+	{
70
+		$controllerFactory = new ControllerFactory($this->pdo, $this->appPath, $this->user);
71
+
72
+		try {
73
+			list($controllerName, $action) = array_values($this->router->route($request->getPath()));
74
+
75
+			/**
76
+			 * Validate and initialize controller
77
+			 */
78
+			try {
79
+				$controller = $controllerFactory->create($controllerName);
80
+			} catch (\Exception $e) {
81
+				if ($e instanceof ControllerNonexistentException || $e instanceof ControllerInvalidSuperclassException) {
82
+					/**
83
+					 * Log invalid superclass
84
+					 */
85
+					if ($this->logger && $e instanceof ControllerInvalidSuperclassException) {
86
+						$this->logger->addCritical('Controller must be an subclass of Zortje\MVC\Controller', [
87
+							'path'       => $request->getPath(),
88
+							'controller' => $controllerName
89
+						]);
90
+					}
91
+
92
+					/**
93
+					 * Log nonexistent
94
+					 */
95
+					if ($this->logger && $e instanceof ControllerNonexistentException) {
96
+						$this->logger->addCritical('Controller is nonexistent', [
97
+							'path'       => $request->getPath(),
98
+							'controller' => $controllerName
99
+						]);
100
+					}
101
+
102
+					$controller = $controllerFactory->create(NotFoundController::class);
103
+					$action     = 'index';
104
+				} else {
105
+					throw $e;
106
+				}
107
+			}
108
+		} catch (RouteNonexistentException $e) {
109
+			/**
110
+			 * Log nonexistent route (404)
111
+			 */
112
+			if ($this->logger) {
113
+				$this->logger->addWarning('Route not connected', [
114
+					'path' => $request->getPath()
115
+				]);
116
+			}
117
+
118
+			$controller = $controllerFactory->create(NotFoundController::class);
119
+			$action     = 'index';
120
+		}
121
+
122
+		/**
123
+		 * Validate and set controller action
124
+		 */
125
+		try {
126
+			$controller->setAction($action);
127
+		} catch (ControllerActionProtectedInsufficientAuthenticationException $e) {
128
+			/**
129
+			 * Log unauthed protected controller action (403)
130
+			 */
131
+			if ($this->logger) {
132
+				$this->logger->addWarning('Unauthenticated attempt to access protected action', [
133
+					'path'       => $request->getPath(),
134
+					'controller' => $controller->getShortName(),
135
+					'action'     => $action
136
+				]);
137
+			}
138
+
139
+			// @todo redirect to login page & and save what action was requested to redirect after successful login
140
+
141
+		} catch (ControllerActionPrivateInsufficientAuthenticationException $e) {
142
+			/**
143
+			 * Log unauthed private controller action (403)
144
+			 */
145
+			if ($this->logger) {
146
+				$this->logger->addWarning('Unauthenticated attempt to access private action', [
147
+					'path'       => $request->getPath(),
148
+					'controller' => $controller->getShortName(),
149
+					'action'     => $action
150
+				]);
151
+			}
152
+
153
+			$controller = $controllerFactory->create(NotFoundController::class);
154
+		} catch (ControllerActionNonexistentException $e) {
155
+			/**
156
+			 * Log nonexistent controller action
157
+			 */
158
+			if ($this->logger) {
159
+				$this->logger->addCritical('Controller action is nonexistent', [
160
+					'path'       => $request->getPath(),
161
+					'controller' => $controller->getShortName(),
162
+					'action'     => $action
163
+				]);
164
+			}
165
+
166
+			$controller = $controllerFactory->create(NotFoundController::class);
167
+		}
168
+
169
+		/**
170
+		 * Create response from controller action headers and output
171
+		 */
172
+		list($headers, $output) = array_values($controller->callAction());
173
+
174
+		/**
175
+		 * Performance logging
176
+		 */
177
+		if ($this->logger) {
178
+			$this->logger->addDebug(vsprintf('Dispatched request in %s ms',
179
+				number_format((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']) * 1000, 2)), [
180
+				'path' => $request->getPath()
181
+			]);
182
+		}
183
+
184
+		return new Response($headers, $output);
185
+	}
186
+
187
+	/**
188
+	 * @param Router    $router
189
+	 * @param \PDO      $pdo
190
+	 * @param string    $appPath
191
+	 * @param null|User $user
192
+	 */
193
+	public function __construct(Router $router, \PDO $pdo, $appPath, User $user = null)
194
+	{
195
+		$this->router  = $router;
196
+		$this->pdo     = $pdo;
197
+		$this->appPath = $appPath;
198
+		$this->user    = $user;
199
+	}
200 200
 
201 201
 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -20,8 +20,7 @@  discard block
 block discarded – undo
20 20
  *
21 21
  * @package Zortje\MVC\Routing
22 22
  */
23
-class Dispatcher
24
-{
23
+class Dispatcher {
25 24
 
26 25
     /**
27 26
      * @var Router
@@ -53,8 +52,7 @@  discard block
 block discarded – undo
53 52
      *
54 53
      * @param Logger $logger
55 54
      */
56
-    public function setLogger(Logger $logger)
57
-    {
55
+    public function setLogger(Logger $logger) {
58 56
         $this->logger = $logger;
59 57
     }
60 58
 
@@ -65,8 +63,7 @@  discard block
 block discarded – undo
65 63
      *
66 64
      * @throws \Exception If unexpected exception is thrown
67 65
      */
68
-    public function dispatch(Request $request)
69
-    {
66
+    public function dispatch(Request $request) {
70 67
         $controllerFactory = new ControllerFactory($this->pdo, $this->appPath, $this->user);
71 68
 
72 69
         try {
@@ -190,8 +187,7 @@  discard block
 block discarded – undo
190 187
      * @param string    $appPath
191 188
      * @param null|User $user
192 189
      */
193
-    public function __construct(Router $router, \PDO $pdo, $appPath, User $user = null)
194
-    {
190
+    public function __construct(Router $router, \PDO $pdo, $appPath, User $user = null) {
195 191
         $this->router  = $router;
196 192
         $this->pdo     = $pdo;
197 193
         $this->appPath = $appPath;
Please login to merge, or discard this patch.
src/Routing/Exception/RouteAlreadyConnectedException.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -12,16 +12,16 @@
 block discarded – undo
12 12
 class RouteAlreadyConnectedException extends Exception
13 13
 {
14 14
 
15
-    /**
16
-     * {@inheritdoc}
17
-     */
18
-    protected $template = 'Route %s is already connected';
15
+	/**
16
+	 * {@inheritdoc}
17
+	 */
18
+	protected $template = 'Route %s is already connected';
19 19
 
20
-    /**
21
-     * {@inheritdoc}
22
-     */
23
-    public function __construct($message)
24
-    {
25
-        parent::__construct($message);
26
-    }
20
+	/**
21
+	 * {@inheritdoc}
22
+	 */
23
+	public function __construct($message)
24
+	{
25
+		parent::__construct($message);
26
+	}
27 27
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,8 +9,7 @@  discard block
 block discarded – undo
9 9
  *
10 10
  * @package Zortje\MVC\Routing\Exception
11 11
  */
12
-class RouteAlreadyConnectedException extends Exception
13
-{
12
+class RouteAlreadyConnectedException extends Exception {
14 13
 
15 14
     /**
16 15
      * {@inheritdoc}
@@ -20,8 +19,7 @@  discard block
 block discarded – undo
20 19
     /**
21 20
      * {@inheritdoc}
22 21
      */
23
-    public function __construct($message)
24
-    {
22
+    public function __construct($message) {
25 23
         parent::__construct($message);
26 24
     }
27 25
 }
Please login to merge, or discard this patch.
src/Routing/Exception/RouteNonexistentException.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -12,16 +12,16 @@
 block discarded – undo
12 12
 class RouteNonexistentException extends Exception
13 13
 {
14 14
 
15
-    /**
16
-     * {@inheritdoc}
17
-     */
18
-    protected $template = 'Route %s is not connected';
15
+	/**
16
+	 * {@inheritdoc}
17
+	 */
18
+	protected $template = 'Route %s is not connected';
19 19
 
20
-    /**
21
-     * {@inheritdoc}
22
-     */
23
-    public function __construct($message)
24
-    {
25
-        parent::__construct($message);
26
-    }
20
+	/**
21
+	 * {@inheritdoc}
22
+	 */
23
+	public function __construct($message)
24
+	{
25
+		parent::__construct($message);
26
+	}
27 27
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,8 +9,7 @@  discard block
 block discarded – undo
9 9
  *
10 10
  * @package Zortje\MVC\Routing\Exception
11 11
  */
12
-class RouteNonexistentException extends Exception
13
-{
12
+class RouteNonexistentException extends Exception {
14 13
 
15 14
     /**
16 15
      * {@inheritdoc}
@@ -20,8 +19,7 @@  discard block
 block discarded – undo
20 19
     /**
21 20
      * {@inheritdoc}
22 21
      */
23
-    public function __construct($message)
24
-    {
22
+    public function __construct($message) {
25 23
         parent::__construct($message);
26 24
     }
27 25
 }
Please login to merge, or discard this patch.
src/Routing/Router.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -13,49 +13,49 @@
 block discarded – undo
13 13
 class Router
14 14
 {
15 15
 
16
-    /**
17
-     * @var array Routes
18
-     */
19
-    protected $routes = [];
20
-
21
-    /**
22
-     * Connects a new route in the router
23
-     *
24
-     * @param string $route      Route
25
-     * @param string $controller Controller
26
-     * @param string $action     Action
27
-     *
28
-     * @throws RouteAlreadyConnectedException When route is already connected
29
-     */
30
-    public function connect($route, $controller, $action)
31
-    {
32
-        if (isset($this->routes[$route]) === true) {
33
-            throw new RouteAlreadyConnectedException([$route]);
34
-        }
35
-
36
-        $this->routes[$route] = [
37
-            'controller' => $controller,
38
-            'action'     => $action
39
-        ];
40
-    }
41
-
42
-    /**
43
-     * Route to get controller and action
44
-     *
45
-     * @param string $route Route
46
-     *
47
-     * @return array Controller and action
48
-     *
49
-     * @throws RouteNonexistentException When route is not connected
50
-     */
51
-    public function route($route)
52
-    {
53
-        if (isset($this->routes[$route]) === false) {
54
-            throw new RouteNonexistentException([$route]);
55
-        }
56
-
57
-        $result = $this->routes[$route];
58
-
59
-        return $result;
60
-    }
16
+	/**
17
+	 * @var array Routes
18
+	 */
19
+	protected $routes = [];
20
+
21
+	/**
22
+	 * Connects a new route in the router
23
+	 *
24
+	 * @param string $route      Route
25
+	 * @param string $controller Controller
26
+	 * @param string $action     Action
27
+	 *
28
+	 * @throws RouteAlreadyConnectedException When route is already connected
29
+	 */
30
+	public function connect($route, $controller, $action)
31
+	{
32
+		if (isset($this->routes[$route]) === true) {
33
+			throw new RouteAlreadyConnectedException([$route]);
34
+		}
35
+
36
+		$this->routes[$route] = [
37
+			'controller' => $controller,
38
+			'action'     => $action
39
+		];
40
+	}
41
+
42
+	/**
43
+	 * Route to get controller and action
44
+	 *
45
+	 * @param string $route Route
46
+	 *
47
+	 * @return array Controller and action
48
+	 *
49
+	 * @throws RouteNonexistentException When route is not connected
50
+	 */
51
+	public function route($route)
52
+	{
53
+		if (isset($this->routes[$route]) === false) {
54
+			throw new RouteNonexistentException([$route]);
55
+		}
56
+
57
+		$result = $this->routes[$route];
58
+
59
+		return $result;
60
+	}
61 61
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,8 +10,7 @@  discard block
 block discarded – undo
10 10
  *
11 11
  * @package Zortje\MVC\Routing
12 12
  */
13
-class Router
14
-{
13
+class Router {
15 14
 
16 15
     /**
17 16
      * @var array Routes
@@ -27,8 +26,7 @@  discard block
 block discarded – undo
27 26
      *
28 27
      * @throws RouteAlreadyConnectedException When route is already connected
29 28
      */
30
-    public function connect($route, $controller, $action)
31
-    {
29
+    public function connect($route, $controller, $action) {
32 30
         if (isset($this->routes[$route]) === true) {
33 31
             throw new RouteAlreadyConnectedException([$route]);
34 32
         }
@@ -48,8 +46,7 @@  discard block
 block discarded – undo
48 46
      *
49 47
      * @throws RouteNonexistentException When route is not connected
50 48
      */
51
-    public function route($route)
52
-    {
49
+    public function route($route) {
53 50
         if (isset($this->routes[$route]) === false) {
54 51
             throw new RouteNonexistentException([$route]);
55 52
         }
Please login to merge, or discard this patch.