1 | <?php |
||
2 | |||
3 | namespace Test; |
||
4 | |||
5 | use CoffeeCode\Router\Router; |
||
6 | |||
7 | class Name |
||
8 | { |
||
9 | /** @var Router */ |
||
10 | private $router; |
||
11 | |||
12 | public function __construct($router) |
||
13 | { |
||
14 | $this->router = $router; |
||
15 | } |
||
16 | |||
17 | public function home(): void |
||
18 | { |
||
19 | echo "<h1>Home</h1>"; |
||
20 | echo "<p>", $this->router->route("name.home"), "</p>"; |
||
21 | echo "<p>", $this->router->route("name.hello"), "</p>"; |
||
22 | echo "<p>", $this->router->route("name.redirect"), "</p>"; |
||
23 | } |
||
24 | |||
25 | public function hello($data): void |
||
0 ignored issues
–
show
|
|||
26 | { |
||
27 | echo "<h1>Hello World</h1>"; |
||
28 | echo "<a href='{$this->router->route("name.params", ["category" => 6, "page" => 1])}'>Route Params</a>"; |
||
29 | } |
||
30 | |||
31 | public function params(array $data): void |
||
32 | { |
||
33 | var_dump($data, $this->router->current()); |
||
0 ignored issues
–
show
|
|||
34 | } |
||
35 | |||
36 | public function redirect($data): void |
||
37 | { |
||
38 | if ($data) { |
||
39 | //$data = category => *, page => * |
||
40 | $this->router->redirect("name.params", $data); |
||
41 | } |
||
42 | |||
43 | $this->router->redirect("name.hello"); |
||
44 | } |
||
45 | } |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.