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 | * View Helper for Aura\Router |
||
4 | * |
||
5 | * PHP version 5 |
||
6 | * |
||
7 | * Copyright (C) 2016 Jake Johns |
||
8 | * |
||
9 | * This software may be modified and distributed under the terms |
||
10 | * of the MIT license. See the LICENSE file for details. |
||
11 | * |
||
12 | * @category ViewHelper |
||
13 | * @package Jnjxp\UrlHelper |
||
14 | * @author Jake Johns <[email protected]> |
||
15 | * @copyright 2016 Jake Johns |
||
16 | * @license http://jnj.mit-license.org/2016 MIT License |
||
17 | * @link http://github.com/jnjxp/jnjxp.urlhelper |
||
18 | */ |
||
19 | |||
20 | namespace Jnjxp\UrlHelper; |
||
21 | |||
22 | use Aura\Router\Generator; |
||
23 | use Aura\Router\Matcher; |
||
24 | |||
25 | use Psr\Http\Message\ServerRequestInterface as Request; |
||
26 | |||
27 | /** |
||
28 | * UrlHelper |
||
29 | * |
||
30 | * @category ViewHelper |
||
31 | * @package Jnjxp\UrlHelper |
||
32 | * @author Jake Johns <[email protected]> |
||
33 | * @license http://jnj.mit-license.org/ MIT License |
||
34 | * @link http://github.com/jnjxp/jnjxp.urlhelper |
||
35 | */ |
||
36 | class UrlHelper |
||
37 | { |
||
38 | /** |
||
39 | * Generates URL paths from routes. |
||
40 | * |
||
41 | * @var Generator |
||
42 | * |
||
43 | * @access protected |
||
44 | */ |
||
45 | protected $generator; |
||
46 | |||
47 | /** |
||
48 | * Contains Matched and Failed route after routing |
||
49 | * |
||
50 | * @var Matcher |
||
51 | * |
||
52 | * @access protected |
||
53 | */ |
||
54 | protected $matcher; |
||
55 | |||
56 | /** |
||
57 | * Request |
||
58 | * |
||
59 | * @var Request |
||
60 | * |
||
61 | * @access protected |
||
62 | */ |
||
63 | protected $request; |
||
64 | |||
65 | /** |
||
66 | * __construct |
||
67 | * |
||
68 | * @param Generator $generator route generator |
||
69 | * @param Matcher $matcher route matcher |
||
70 | * |
||
71 | * @access public |
||
72 | */ |
||
73 | 10 | public function __construct(Generator $generator, Matcher $matcher) |
|
74 | { |
||
75 | 10 | $this->generator = $generator; |
|
76 | 10 | $this->matcher = $matcher; |
|
77 | 10 | } |
|
78 | |||
79 | /** |
||
80 | * Generate URL or return helper |
||
81 | * |
||
82 | * @param string $name route name |
||
83 | * @param array $data array of params |
||
84 | * |
||
85 | * @return $this|string |
||
86 | * |
||
87 | * @access public |
||
88 | */ |
||
89 | 2 | public function __invoke($name = null, $data = []) |
|
90 | { |
||
91 | 2 | if (null === $name) { |
|
92 | 1 | return $this; |
|
93 | } |
||
94 | 1 | return $this->generate($name, $data); |
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
![]() |
|||
95 | } |
||
96 | |||
97 | /** |
||
98 | * Set current request |
||
99 | * |
||
100 | * @param Request $request current request |
||
101 | * |
||
102 | * @return Request |
||
103 | * @throws Exception if request already set |
||
104 | * |
||
105 | * @access public |
||
106 | */ |
||
107 | 2 | public function setRequest(Request $request) |
|
108 | { |
||
109 | 2 | if (null !== $this->request) { |
|
110 | 1 | throw new \Exception('Request already set'); |
|
111 | } |
||
112 | 2 | $this->request = $request; |
|
113 | 2 | } |
|
114 | |||
115 | /** |
||
116 | * Get current request |
||
117 | * |
||
118 | * @return Request |
||
119 | * |
||
120 | * @access public |
||
121 | */ |
||
122 | 1 | public function getRequest() |
|
123 | { |
||
124 | 1 | return $this->request; |
|
125 | } |
||
126 | |||
127 | /** |
||
128 | * Get current route |
||
129 | * |
||
130 | * @return \Aura\Router\Route|false |
||
131 | * |
||
132 | * @access public |
||
133 | */ |
||
134 | 1 | public function getRoute() |
|
135 | { |
||
136 | 1 | return $this->matcher->getMatchedRoute(); |
|
137 | } |
||
138 | |||
139 | /** |
||
140 | * Get failed route |
||
141 | * |
||
142 | * @return \Aura\Router\Route |
||
143 | * |
||
144 | * @access public |
||
145 | */ |
||
146 | 1 | public function getFailedRoute() |
|
147 | { |
||
148 | 1 | return $this->matcher->getFailedRoute(); |
|
149 | } |
||
150 | |||
151 | /** |
||
152 | * Generate URL |
||
153 | * |
||
154 | * @param string $name name of route |
||
155 | * @param array $data params |
||
156 | * |
||
157 | * @return string |
||
158 | * |
||
159 | * @access public |
||
160 | */ |
||
161 | 2 | public function generate($name, $data = []) |
|
162 | { |
||
163 | 2 | return $this->generator->generate($name, $data); |
|
164 | } |
||
165 | |||
166 | /** |
||
167 | * Generate raw URL |
||
168 | * |
||
169 | * @param string $name name of route |
||
170 | * @param array $data params |
||
171 | * |
||
172 | * @return string |
||
173 | * |
||
174 | * @access public |
||
175 | */ |
||
176 | 1 | public function generateRaw($name, $data = []) |
|
177 | { |
||
178 | 1 | return $this->generator->generateRaw($name, $data); |
|
179 | } |
||
180 | } |
||
181 |