This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of the Tadcka package. |
||
5 | * |
||
6 | * (c) Tadas Gliaubicas <[email protected]> |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace Tadcka\Component\Routing\Manager; |
||
13 | |||
14 | use Tadcka\Component\Routing\Exception\RoutingRuntimeException; |
||
15 | use Tadcka\Component\Routing\Model\Manager\RouteManager; |
||
16 | use Tadcka\Component\Routing\Model\Manager\RouteManagerInterface; |
||
17 | use Tadcka\Component\Routing\Model\RouteInterface; |
||
18 | |||
19 | /** |
||
20 | * @author Tadas Gliaubicas <[email protected]> |
||
21 | * |
||
22 | * @since 9/1/14 8:30 PM |
||
23 | */ |
||
24 | class InMemoryRouteManager extends RouteManager |
||
25 | { |
||
26 | /** |
||
27 | * @var RouteManagerInterface |
||
28 | */ |
||
29 | private $routeManager; |
||
30 | |||
31 | /** |
||
32 | * @var array|RouteInterface[] |
||
33 | */ |
||
34 | private $routes = array(); |
||
35 | |||
36 | /** |
||
37 | * Constructor. |
||
38 | * |
||
39 | * @param RouteManagerInterface $routeManager |
||
40 | */ |
||
41 | 1 | public function __construct(RouteManagerInterface $routeManager) |
|
42 | { |
||
43 | 1 | $this->routeManager = $routeManager; |
|
44 | 1 | } |
|
45 | |||
46 | /** |
||
47 | * {@inheritdoc} |
||
48 | */ |
||
49 | public function findAllNameAndPattern() |
||
50 | { |
||
51 | return $this->routeManager->findAllNameAndPattern(); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * {@inheritdoc} |
||
56 | */ |
||
57 | public function findByName($name) |
||
58 | { |
||
59 | if (isset($this->routes[$name])) { |
||
60 | return $this->routes[$name]; |
||
61 | } |
||
62 | |||
63 | return $this->routeManager->findByName($name); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * {@inheritdoc} |
||
68 | */ |
||
69 | public function findVisibleByName($name) |
||
70 | { |
||
71 | if (isset($this->routes[$name])) { |
||
72 | $route = $this->routes[$name]; |
||
73 | |||
74 | return $route->isVisible() ? $route : null; |
||
75 | } |
||
76 | |||
77 | return $this->routeManager->findVisibleByName($name); |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * {@inheritdoc} |
||
82 | */ |
||
83 | public function findByNames(array $names) |
||
84 | { |
||
85 | $routes = array(); |
||
86 | $diffNames = array_diff($names, array_keys($this->routes)); |
||
87 | |||
88 | foreach ($this->routes as $name => $route) { |
||
89 | if (in_array($name, $names)) { |
||
90 | $routes[] = $route; |
||
91 | } |
||
92 | } |
||
93 | |||
94 | return array_merge($routes, $this->routeManager->findByNames($diffNames)); |
||
95 | } |
||
96 | |||
97 | /** |
||
98 | * {@inheritdoc} |
||
99 | */ |
||
100 | View Code Duplication | public function findVisibleByNames(array $names) |
|
0 ignored issues
–
show
|
|||
101 | { |
||
102 | $routes = array(); |
||
103 | $diffNames = array_diff($names, array_keys($this->routes)); |
||
104 | |||
105 | foreach ($this->routes as $name => $route) { |
||
106 | if (in_array($name, $names) && $route->isVisible()) { |
||
107 | $routes[] = $route; |
||
108 | } |
||
109 | } |
||
110 | |||
111 | return array_merge($routes, $this->routeManager->findVisibleByNames($diffNames)); |
||
112 | } |
||
113 | |||
114 | /** |
||
115 | * {@inheritdoc} |
||
116 | */ |
||
117 | public function findByRoutePattern($routePattern) |
||
118 | { |
||
119 | foreach ($this->routes as $route) { |
||
120 | if ($routePattern === $route->getRoutePattern()) { |
||
121 | return $route; |
||
122 | } |
||
123 | } |
||
124 | |||
125 | return $this->routeManager->findByRoutePattern($routePattern); |
||
126 | } |
||
127 | |||
128 | /** |
||
129 | * {@inheritdoc} |
||
130 | */ |
||
131 | View Code Duplication | public function findByRoutePatterns(array $routePatterns) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
132 | { |
||
133 | $result = array(); |
||
134 | foreach ($routePatterns as $routePattern) { |
||
135 | foreach ($this->routes as $route) { |
||
136 | if ($routePattern === $route->getRoutePattern()) { |
||
137 | $result[$routePattern] = $route; |
||
138 | } |
||
139 | } |
||
140 | } |
||
141 | |||
142 | $diffRoutePatterns = array_diff($routePatterns, array_keys($result)); |
||
143 | |||
144 | return array_merge(array_values($result), $this->routeManager->findByRoutePatterns($diffRoutePatterns)); |
||
145 | } |
||
146 | |||
147 | /** |
||
148 | * {@inheritdoc} |
||
149 | */ |
||
150 | View Code Duplication | public function findVisibleByRoutePatterns(array $routePatterns) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
151 | { |
||
152 | $result = array(); |
||
153 | foreach ($routePatterns as $routePattern) { |
||
154 | foreach ($this->routes as $route) { |
||
155 | if (($routePattern === $route->getRoutePattern()) && $route->isVisible()) { |
||
156 | $result[$routePattern] = $route; |
||
157 | } |
||
158 | } |
||
159 | } |
||
160 | |||
161 | $diffRoutePatterns = array_diff($routePatterns, array_keys($result)); |
||
162 | |||
163 | return array_merge(array_values($result), $this->routeManager->findVisibleByRoutePatterns($diffRoutePatterns)); |
||
164 | } |
||
165 | |||
166 | /** |
||
167 | * {@inheritdoc} |
||
168 | */ |
||
169 | public function all() |
||
170 | { |
||
171 | $routes = $this->routes; |
||
172 | foreach ($this->routeManager->all() as $route) { |
||
173 | if (false === isset($routes[$route->getName()])) { |
||
174 | $routes[$route->getName()] = $route; |
||
175 | } |
||
176 | } |
||
177 | |||
178 | return array_values($routes); |
||
179 | } |
||
180 | |||
181 | /** |
||
182 | * {@inheritdoc} |
||
183 | */ |
||
184 | 1 | public function add(RouteInterface $route, $save = false) |
|
185 | { |
||
186 | 1 | if (!$route->getName()) { |
|
187 | 1 | throw new RoutingRuntimeException('Route name is empty!'); |
|
188 | } |
||
189 | |||
190 | $this->routes[$route->getName()] = $route; |
||
191 | $this->routeManager->add($route, $save); |
||
192 | } |
||
193 | |||
194 | /** |
||
195 | * {@inheritdoc} |
||
196 | */ |
||
197 | public function remove(RouteInterface $route, $save = false) |
||
198 | { |
||
199 | if (isset($this->routes[$route->getName()])) { |
||
200 | unset($this->routes[$route->getName()]); |
||
201 | } |
||
202 | $this->routeManager->remove($route, $save); |
||
203 | } |
||
204 | |||
205 | /** |
||
206 | * {@inheritdoc} |
||
207 | */ |
||
208 | public function save() |
||
209 | { |
||
210 | $this->routeManager->save(); |
||
211 | } |
||
212 | |||
213 | /** |
||
214 | * {@inheritdoc} |
||
215 | */ |
||
216 | public function clear() |
||
217 | { |
||
218 | $this->routes = array(); |
||
219 | $this->routeManager->clear(); |
||
220 | } |
||
221 | |||
222 | /** |
||
223 | * {@inheritdoc} |
||
224 | */ |
||
225 | public function getClass() |
||
226 | { |
||
227 | return $this->routeManager->getClass(); |
||
228 | } |
||
229 | } |
||
230 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.