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

HasMatcherTrait::matchRequest()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2.864

Importance

Changes 0
Metric Value
cc 2
eloc 4
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 8
ccs 2
cts 5
cp 0.4
crap 2.864
rs 10
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