Issues (10)

example/components/IpCheckEventHandler.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace example\components;
4
5
use Tebe\Pvc\Application;
6
use Tebe\Pvc\Event\Event;
7
use Tebe\Pvc\Event\EventHandler;
8
9
class IpCheckEventHandler implements EventHandler
10
{
11
12
    protected $blockedIps;
13
14
    public function __construct($blockedIps)
15
    {
16
        $this->blockedIps = $blockedIps;
17
    }
18
19
    public function handle(Event $event) : void
20
    {
21
        $request  = Application::instance()->getRequest();
22
        $ipAdress = $request->getRemoteAddress();
0 ignored issues
show
The method getRemoteAddress() does not exist on Psr\Http\Message\ServerRequestInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

22
        /** @scrutinizer ignore-call */ 
23
        $ipAdress = $request->getRemoteAddress();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
23
24
        if (in_array($ipAdress, $this->blockedIps)) {
25
            $event->cancel();
26
        }
27
    }
28
}
29