Passed
Push — master ( 5383f1...af8f48 )
by Gabriel
03:29
created

HasMatcherTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 40%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 5
c 1
b 0
f 1
dl 0
loc 14
ccs 2
cts 5
cp 0.4
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A matchRequest() 0 8 2
1
<?php
2
3
namespace Nip\Router\Router\Traits;
4
5
use \Symfony\Component\HttpFoundation\Request;
6
use Nip\Router\Route\Route;
7
use Psr\Http\Message\ServerRequestInterface;
8
9
/**
10
 * Trait HasMatcherTrait
11
 * @package Nip\Router\Router\Traits
12
 */
13
trait HasMatcherTrait
14
{
15
    /**
16
     * @param Request|ServerRequestInterface $request
17
     * @return array
18
     */
19 2
    public function matchRequest(Request $request)
20
    {
21 2
        $return = parent::matchRequest($request);
22
        if (isset($return['_route'])) {
23
            $this->setCurrent($return['_route']);
0 ignored issues
show
Bug introduced by
It seems like setCurrent() 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

23
            $this->/** @scrutinizer ignore-call */ 
24
                   setCurrent($return['_route']);
Loading history...
24
//            $this->setCurrent($this->getRoute($return['_route']));
25
        }
26
        return $return;
27
    }
28
}
29