@@ -40,10 +40,10 @@ |
||
40 | 40 | */ |
41 | 41 | public function testCreateUserView() |
42 | 42 | { |
43 | - $http = $this->http->get('users/create'); |
|
44 | - $output = $http->getBody()->getContents(); |
|
45 | - $this->assertEquals(200, $http->getStatusCode()); |
|
46 | - $this->assertEquals('view create user', $output); |
|
43 | + $http = $this->http->get('users/create'); |
|
44 | + $output = $http->getBody()->getContents(); |
|
45 | + $this->assertEquals(200, $http->getStatusCode()); |
|
46 | + $this->assertEquals('view create user', $output); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -21,11 +21,11 @@ |
||
21 | 21 | */ |
22 | 22 | public static function factory($typeResponse, Request $request, Response $response) |
23 | 23 | { |
24 | - if(is_bool($typeResponse)) { |
|
25 | - return $response->setContent((string)$typeResponse)->send(); |
|
24 | + if (is_bool($typeResponse)) { |
|
25 | + return $response->setContent((string) $typeResponse)->send(); |
|
26 | 26 | } |
27 | 27 | $baseResponse = RouteResponse::create($typeResponse); |
28 | - if(is_array($typeResponse)) { |
|
28 | + if (is_array($typeResponse)) { |
|
29 | 29 | return (new JsonResponse($baseResponse, $request, $response))->render(); |
30 | 30 | } |
31 | 31 | return (new TextPlainResponse($baseResponse, $request, $response))->render(); |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | protected function uri() : string |
102 | 102 | { |
103 | - return trim(strtok( $_SERVER['REQUEST_URI'], '?'), '/'); |
|
103 | + return trim(strtok($_SERVER['REQUEST_URI'], '?'), '/'); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -120,13 +120,13 @@ discard block |
||
120 | 120 | */ |
121 | 121 | protected function checkCommonProblems() |
122 | 122 | { |
123 | - if(self::hasRouteValid()) { |
|
123 | + if (self::hasRouteValid()) { |
|
124 | 124 | return false; |
125 | 125 | } |
126 | - if(empty( $this->routeStack)) { |
|
126 | + if (empty($this->routeStack)) { |
|
127 | 127 | throw new \InvalidArgumentException('Routing empty'); |
128 | 128 | } |
129 | - if(!isset($this->routeStack[self::method()])) { |
|
129 | + if (!isset($this->routeStack[self::method()])) { |
|
130 | 130 | throw new MethodNotAllowedException('Requested method was not scaled.'); |
131 | 131 | } |
132 | 132 | return true; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | { |
146 | 146 | $route = new Route($path, $callable); |
147 | 147 | $this->routeStack[$method][] = $route; |
148 | - if($name) { |
|
148 | + if ($name) { |
|
149 | 149 | $this->routesGroupByName[$name] = $route; |
150 | 150 | } |
151 | 151 | return $route; |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | { |
161 | 161 | foreach ($this->routeStack[self::method()] as $route) { |
162 | 162 | /** @var $route Route */ |
163 | - if($route->extractParameters(self::uri())) { |
|
163 | + if ($route->extractParameters(self::uri())) { |
|
164 | 164 | return $route->run(); |
165 | 165 | } |
166 | 166 | } |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | */ |
178 | 178 | public function goUrl($name, $params = []) |
179 | 179 | { |
180 | - if(!isset($this->routesGroupByName[$name])) { |
|
181 | - throw new UnregisteredRouteException('Unregistered route by name ' . $name); |
|
180 | + if (!isset($this->routesGroupByName[$name])) { |
|
181 | + throw new UnregisteredRouteException('Unregistered route by name '.$name); |
|
182 | 182 | } |
183 | 183 | /** @var Route $route */ |
184 | 184 | $route = $this->routesGroupByName[$name]; |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | protected static function createReflection($object, string $method = null) |
27 | 27 | { |
28 | 28 | self::$reflectionObject = $object; |
29 | - if($method) { |
|
29 | + if ($method) { |
|
30 | 30 | self::$resolveMethodName = $method; |
31 | 31 | } |
32 | 32 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | protected static function getPointersAndReturnRequired(int $position) |
39 | 39 | { |
40 | - return self::$parameters[ array_flip( self::$numberOfParameters)[$position] ]; |
|
40 | + return self::$parameters[array_flip(self::$numberOfParameters)[$position]]; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -48,16 +48,16 @@ discard block |
||
48 | 48 | { |
49 | 49 | $attributes = []; |
50 | 50 | $parameters = self::getParametersObject(); |
51 | - if(count($parameters) > 0) { |
|
51 | + if (count($parameters) > 0) { |
|
52 | 52 | foreach ($parameters as $parameter) { |
53 | 53 | /** @var \ReflectionParameter $parameter */ |
54 | - if(!$parameter->getClass()) { |
|
54 | + if (!$parameter->getClass()) { |
|
55 | 55 | self::$numberOfParameters[] = $parameter->getPosition(); |
56 | 56 | $attributes[$parameter->getPosition()] = self::getPointersAndReturnRequired($parameter->getPosition()); |
57 | 57 | continue; |
58 | 58 | } |
59 | 59 | $className = $parameter->getClass()->getName(); |
60 | - if(self::checkClassRegisterContainer($className)) { |
|
60 | + if (self::checkClassRegisterContainer($className)) { |
|
61 | 61 | $attributes[$parameter->getPosition()] = Kernel::getContainer()->get($className); |
62 | 62 | } |
63 | 63 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | protected static function checkClassRegisterContainer(string $className) |
75 | 75 | { |
76 | - if(!Kernel::getContainer()->has($className)) { |
|
76 | + if (!Kernel::getContainer()->has($className)) { |
|
77 | 77 | throw new ContainerException("Class [{$className}] not registered in the container."); |
78 | 78 | } |
79 | 79 | return true; |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | */ |
87 | 87 | protected static function getParametersObject() |
88 | 88 | { |
89 | - if( self::$reflectionObject instanceof \ReflectionClass) { |
|
89 | + if (self::$reflectionObject instanceof \ReflectionClass) { |
|
90 | 90 | $method = self::$reflectionObject->getMethod(self::$resolveMethodName); |
91 | 91 | return $method->getParameters(); |
92 | 92 | } |
93 | - if ( self::$reflectionObject instanceof \ReflectionFunction) { |
|
93 | + if (self::$reflectionObject instanceof \ReflectionFunction) { |
|
94 | 94 | return self::$reflectionObject->getParameters(); |
95 | 95 | } |
96 | 96 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | */ |
21 | 21 | public static function getContainer(): Container |
22 | 22 | { |
23 | - if( null === self::$instance) { |
|
23 | + if (null === self::$instance) { |
|
24 | 24 | $container = new Container(); |
25 | 25 | $container->addServiceProvider(new RouteServiceProvider()); |
26 | 26 | self::$instance = $container; |
@@ -132,10 +132,10 @@ discard block |
||
132 | 132 | public function getRoute() |
133 | 133 | { |
134 | 134 | return [ |
135 | - 'name' => $this->getName(), |
|
136 | - 'path' => $this->getUrl(), |
|
137 | - 'callable' => $this->getCallable(), |
|
138 | - 'parameters' => self::resolveParameters() |
|
135 | + 'name' => $this->getName(), |
|
136 | + 'path' => $this->getUrl(), |
|
137 | + 'callable' => $this->getCallable(), |
|
138 | + 'parameters' => self::resolveParameters() |
|
139 | 139 | ]; |
140 | 140 | } |
141 | 141 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function getRequest(): Request |
148 | 148 | { |
149 | - return $this->request; |
|
149 | + return $this->request; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function getResponse(): Response |
158 | 158 | { |
159 | - return $this->response; |
|
159 | + return $this->response; |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | { |
64 | 64 | $url = trim($url, '/'); |
65 | 65 | $path = preg_replace_callback('#:([\w]+)#', [$this, 'attributesMatch'], $this->getUrl()); |
66 | - if(!preg_match("#^$path$#i", $url, $matches)) { |
|
66 | + if (!preg_match("#^$path$#i", $url, $matches)) { |
|
67 | 67 | return false; |
68 | 68 | } |
69 | 69 | array_shift($matches); |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | * @return string |
79 | 79 | */ |
80 | 80 | private function attributesMatch($match) { |
81 | - if(isset(self::$attributes[$match[1]])) { |
|
82 | - return '(' . self::$attributes[$match[1]] . ')'; |
|
81 | + if (isset(self::$attributes[$match[1]])) { |
|
82 | + return '('.self::$attributes[$match[1]].')'; |
|
83 | 83 | } |
84 | 84 | return '([^/]+)'; |
85 | 85 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function run() |
197 | 197 | { |
198 | - if(is_string($this->getCallable())) { |
|
198 | + if (is_string($this->getCallable())) { |
|
199 | 199 | return $this->handleRequestController(); |
200 | 200 | } |
201 | 201 | return $this->handleRequestCallable(); |