@@ -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(); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | protected static function getPointersAndReturnRequired(int $position) |
62 | 62 | { |
63 | - return self::$parameters[ array_flip( self::$numberOfParameters)[$position] ]; |
|
63 | + return self::$parameters[array_flip(self::$numberOfParameters)[$position]]; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -71,16 +71,16 @@ discard block |
||
71 | 71 | { |
72 | 72 | $attributes = []; |
73 | 73 | $parameters = self::getParametersObject(); |
74 | - if(count($parameters) > 0) { |
|
74 | + if (count($parameters) > 0) { |
|
75 | 75 | foreach ($parameters as $parameter) { |
76 | 76 | /** @var \ReflectionParameter $parameter */ |
77 | - if(!$parameter->getClass()) { |
|
77 | + if (!$parameter->getClass()) { |
|
78 | 78 | self::$numberOfParameters[] = $parameter->getPosition(); |
79 | 79 | $attributes[$parameter->getPosition()] = self::getPointersAndReturnRequired($parameter->getPosition()); |
80 | 80 | continue; |
81 | 81 | } |
82 | 82 | $className = $parameter->getClass()->getName(); |
83 | - if(self::checkClassRegisterContainer($className)) { |
|
83 | + if (self::checkClassRegisterContainer($className)) { |
|
84 | 84 | $attributes[$parameter->getPosition()] = Kernel::getContainer()->get($className); |
85 | 85 | } |
86 | 86 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | */ |
97 | 97 | protected static function checkClassRegisterContainer(string $className) |
98 | 98 | { |
99 | - if(!Kernel::getContainer()->has($className)) { |
|
99 | + if (!Kernel::getContainer()->has($className)) { |
|
100 | 100 | throw new ContainerException("Class [{$className}] not registered in the container."); |
101 | 101 | } |
102 | 102 | return true; |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | */ |
110 | 110 | protected static function getParametersObject() |
111 | 111 | { |
112 | - if( self::$reflectionObject instanceof \ReflectionClass) { |
|
112 | + if (self::$reflectionObject instanceof \ReflectionClass) { |
|
113 | 113 | $method = self::$reflectionObject->getMethod(self::$resolveMethodName); |
114 | 114 | return $method->getParameters(); |
115 | 115 | } |
116 | - if ( self::$reflectionObject instanceof \ReflectionFunction) { |
|
116 | + if (self::$reflectionObject instanceof \ReflectionFunction) { |
|
117 | 117 | return self::$reflectionObject->getParameters(); |
118 | 118 | } |
119 | 119 | } |