Completed
Push — master ( 1481a4...14a440 )
by Dan
05:18
created
Tests/Router/RouterTest.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -44,45 +44,45 @@
 block discarded – undo
44 44
         );
45 45
     }
46 46
 
47
-    public function testGetAdaptor(){
47
+    public function testGetAdaptor() {
48 48
         $expected = $this->adaptor;
49 49
         $actual = $this->router->getAdaptor();
50 50
         $this->assertEquals($expected, $actual);
51 51
     }
52 52
 
53
-    public function testWithAdaptor(){
53
+    public function testWithAdaptor() {
54 54
         $newAdaptor = $this->getMockBuilder('\Ds\Router\AdaptorInterface')->getMock();
55 55
         $newRouter = $this->router->withAdaptor($newAdaptor);
56 56
         $this->assertNotSame($this->adaptor, $newRouter->getAdaptor());
57 57
     }
58 58
 
59
-    public function testGetRouterResponse(){
59
+    public function testGetRouterResponse() {
60 60
 
61 61
         $request = $this->getMockBuilder('\Psr\Http\Message\RequestInterface')->getMock();
62 62
 
63
-        $routerResponse = new RouterResponse(200,[],null,[]);
63
+        $routerResponse = new RouterResponse(200, [], null, []);
64 64
 
65
-        $this->adaptor->expects( $this->once() )
65
+        $this->adaptor->expects($this->once())
66 66
             ->method('match')
67 67
             ->willReturn($routerResponse);
68 68
 
69
-        $this->routes->expects( $this->once() )
69
+        $this->routes->expects($this->once())
70 70
             ->method('getRoutes')
71 71
             ->willReturn([]);
72 72
 
73 73
         $response = $this->router->getRouterResponse($request);
74
-        $this->assertInstanceOf('\Ds\Router\RouterResponseInterface' , $response);
74
+        $this->assertInstanceOf('\Ds\Router\RouterResponseInterface', $response);
75 75
 
76 76
     }
77 77
 
78
-    public function testWithRoutes(){
78
+    public function testWithRoutes() {
79 79
 
80 80
         $routes = $this->getMockBuilder('\Ds\Router\RoutesInterface')->getMock();
81 81
         $this->router->withRoutes($routes);
82 82
 
83
-        $reflector = new \ReflectionClass( '\Ds\Router\Router' );
84
-        $prop = $reflector->getProperty( 'routes' );
85
-        $prop->setAccessible( true );
83
+        $reflector = new \ReflectionClass('\Ds\Router\Router');
84
+        $prop = $reflector->getProperty('routes');
85
+        $prop->setAccessible(true);
86 86
 
87 87
         $this->assertSame($routes, $prop->getValue($this->router));
88 88
 
Please login to merge, or discard this patch.
Src/Router/Adaptor/FastRoute.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
         $this->options = $options;
24 24
         $this->checkCacheFile();
25 25
 
26
-        if (!isset($this->options['errorHandlers']['default'])){
26
+        if (!isset($this->options['errorHandlers']['default'])) {
27 27
             throw new \Exception('Error Handlers must be specified');
28 28
         }
29 29
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      * Check cache file and update self::$cacheDisabled
36 36
      * @return bool
37 37
      */
38
-    public function checkCacheFile(){
38
+    public function checkCacheFile() {
39 39
         $cacheDir = isset($this->options['cacheFile'])
40 40
             ? $this->options['cacheFile'] : __DIR__;
41 41
 
@@ -56,11 +56,11 @@  discard block
 block discarded – undo
56 56
      * @param string $requestTarget
57 57
      * @return RouterResponse
58 58
      */
59
-    public function match(array $routes, $method, $requestTarget){
59
+    public function match(array $routes, $method, $requestTarget) {
60 60
 
61 61
         //remove end slash variation.
62
-        $formattedRequest = rtrim($requestTarget,"/");
63
-        $formattedRequest = $formattedRequest."/";
62
+        $formattedRequest = rtrim($requestTarget, "/");
63
+        $formattedRequest = $formattedRequest . "/";
64 64
 
65 65
         $response = [
66 66
             'statusCode' => 500,
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
             'vars' => []
69 69
         ];
70 70
 
71
-        $routeInfo =  $this->getCachedDispatcher($routes)->dispatch($method, $formattedRequest);
71
+        $routeInfo = $this->getCachedDispatcher($routes)->dispatch($method, $formattedRequest);
72 72
 
73 73
         switch ($routeInfo[0]) {
74 74
             case Dispatcher::FOUND:
@@ -103,10 +103,10 @@  discard block
 block discarded – undo
103 103
      * @param $code
104 104
      * @return mixed
105 105
      */
106
-    public function findHandler($code){
106
+    public function findHandler($code) {
107 107
         $handlerName = $this->options['handler'];
108 108
         $handlerArgs = $this->options['errorHandlers']['default'];
109
-        if (isset($this->options['errorHandlers'][$code])){
109
+        if (isset($this->options['errorHandlers'][$code])) {
110 110
             $handlerArgs = $this->options['errorHandlers'][$code];
111 111
         }
112 112
 
@@ -121,12 +121,12 @@  discard block
 block discarded – undo
121 121
      * @param array $routes
122 122
      * @return FastRouteAdaptor
123 123
      */
124
-    public function getCachedDispatcher(array $routes = []){
124
+    public function getCachedDispatcher(array $routes = []) {
125 125
 
126 126
         return \FastRoute\cachedDispatcher(
127 127
             function(RouteCollector $r) use ($routes){
128
-                foreach($routes as $route){
129
-                   $r->addRoute($route['method'],$route['pattern'],$route['handler']);
128
+                foreach ($routes as $route) {
129
+                   $r->addRoute($route['method'], $route['pattern'], $route['handler']);
130 130
                 }
131 131
             },
132 132
            $this->options
Please login to merge, or discard this patch.