1 | <?php |
||||||
2 | namespace Moody\ControllerIP; |
||||||
3 | |||||||
4 | use Anax\Commons\ContainerInjectableInterface; |
||||||
5 | use Anax\Commons\ContainerInjectableTrait; |
||||||
6 | |||||||
7 | // use Anax\Route\Exception\ForbiddenException; |
||||||
8 | // use Anax\Route\Exception\NotFoundException; |
||||||
9 | // use Anax\Route\Exception\InternalErrorException; |
||||||
10 | |||||||
11 | /** |
||||||
12 | * A sample controller to show how a controller class can be implemented. |
||||||
13 | * The controller will be injected with $di if implementing the interface |
||||||
14 | * ContainerInjectableInterface, like this sample class does. |
||||||
15 | * The controller is mounted on a particular route and can then handle all |
||||||
16 | * requests for that mount point. |
||||||
17 | * |
||||||
18 | * @SuppressWarnings(PHPMD.TooManyPublicMethods) |
||||||
19 | */ |
||||||
20 | class IpController implements ContainerInjectableInterface |
||||||
21 | { |
||||||
22 | use ContainerInjectableTrait; |
||||||
23 | |||||||
24 | private $ipAddress; |
||||||
25 | private $object; |
||||||
26 | |||||||
27 | |||||||
28 | 2 | public function result($ipAddress, $object) : string |
|||||
29 | { |
||||||
30 | 2 | if ($object->getProtocol($ipAddress)) { |
|||||
31 | 1 | return "The IP $ipAddress is a valid " . $object->getProtocol($ipAddress) ." address." ; |
|||||
32 | } |
||||||
33 | 1 | return "The IP $ipAddress is not a valid ip-Address."; |
|||||
34 | } |
||||||
35 | |||||||
36 | 1 | public function indexAction() : object |
|||||
37 | { |
||||||
38 | // Deal with the action and return a response. |
||||||
39 | 1 | $protocol = null; |
|||||
0 ignored issues
–
show
Unused Code
introduced
by
![]() |
|||||||
40 | 1 | $host = null; |
|||||
0 ignored issues
–
show
|
|||||||
41 | 1 | $address = null; |
|||||
0 ignored issues
–
show
|
|||||||
42 | |||||||
43 | 1 | $title = "Ip validator"; |
|||||
44 | 1 | $page = $this->di->get("page"); |
|||||
45 | 1 | $request = $this->di->get("request"); |
|||||
46 | 1 | $this->ipAddress = $request->getGet("ip"); |
|||||
47 | 1 | $ip = $this->ipAddress; |
|||||
0 ignored issues
–
show
|
|||||||
48 | |||||||
49 | 1 | $this->object = new IpValidate(); |
|||||
50 | 1 | $protocol = $this->result($this->ipAddress, $this->object); |
|||||
51 | 1 | $host = $this->object->getDomain($this->ipAddress); |
|||||
52 | 1 | $address = $this->object->getAddress($this->ipAddress); |
|||||
53 | 1 | $ip = $this->object->getCurrentIp($this->ipAddress); |
|||||
0 ignored issues
–
show
The call to
Moody\ControllerIP\IpValidate::getCurrentIp() has too many arguments starting with $this->ipAddress .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. ![]() |
|||||||
54 | 1 | $Domain = $this->object->getDomain($this->ipAddress); |
|||||
55 | |||||||
56 | |||||||
57 | 1 | $data["ip"] = $ip; |
|||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
58 | 1 | $data["protocol"] = $protocol; |
|||||
59 | 1 | $data["host"] = $host; |
|||||
60 | 1 | $data["address"] = $address; |
|||||
61 | 1 | $data["Domain"] = $Domain; |
|||||
62 | |||||||
63 | |||||||
64 | 1 | $page->add("id/index", $data); |
|||||
65 | 1 | return $page->render([ |
|||||
66 | 1 | "title" => $title, |
|||||
67 | ]); |
||||||
68 | } |
||||||
69 | } |
||||||
70 |