Issues (105)

src/Route/Traits/HasMatchTrait.php (2 issues)

1
<?php
2
3
namespace Nip\Router\Route\Traits;
4
5
/**
6
 * Trait HasMatchTrait
7
 * @package Nip\Router\Route\Traits
8
 */
9
trait HasMatchTrait
10
{
11
12
    /**
13
     * @param $uri
14
     * @return bool
15
     */
16
    public function match($uri)
17
    {
18
        $this->uri = $uri;
0 ignored issues
show
Bug Best Practice introduced by
The property uri does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
19
        if ($this->domainCheck()) {
20
            $return = $this->getParser()->match($uri);
0 ignored issues
show
It seems like getParser() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

20
            $return = $this->/** @scrutinizer ignore-call */ getParser()->match($uri);
Loading history...
21
            if ($return === true) {
22
                $this->postMatch();
23
            }
24
25
            return $return;
26
        }
27
28
        return false;
29
    }
30
31
    /**
32
     * @return bool
33
     */
34
    public function domainCheck()
35
    {
36
        return true;
37
    }
38
39
    public function postMatch()
40
    {
41
    }
42
}
43