HasRequestTrait   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A setRequest() 0 7 1
1
<?php
2
3
namespace Nip\Router\Generator\Traits;
4
5
use Nip\Request;
6
use Nip\Router\RequestContext;
7
8
/**
9
 * Trait HasRequestTrait
10
 * @package Nip\Router\Generator\Traits
11
 */
12
trait HasRequestTrait
13
{
14
15
    /**
16
     * Set the current request instance.
17
     *
18
     * @param  Request $request
19
     */
20
    public function setRequest(Request $request)
21
    {
22
        $context = (new RequestContext())->fromRequest($request);
23
24
        $this->cachedRoot = null;
0 ignored issues
show
Bug Best Practice introduced by
The property cachedRoot does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
25
        $this->cachedSchema = null;
0 ignored issues
show
Bug Best Practice introduced by
The property cachedSchema does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
26
        return $this->setContext($context);
0 ignored issues
show
Bug introduced by
It seems like setContext() 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

26
        return $this->/** @scrutinizer ignore-call */ setContext($context);
Loading history...
27
    }
28
}
29