Passed
Pull Request — master (#60)
by
unknown
10:40
created

DispatcherAwareTrait::withDispatcher()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Router\Dispatcher;
6
7
trait DispatcherAwareTrait
8
{
9
    private ?DispatcherInterface $dispatcher = null;
10
11
    public function getDispatcher(): ?DispatcherInterface
12
    {
13
        return $this->dispatcher;
14
    }
15
16
    public function withDispatcher(DispatcherInterface $dispatcher): DispatcherAwareInterface
17
    {
18
        $new = clone $this;
19
        $new->dispatcher = $dispatcher;
20
        return $new;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $new returns the type Yiisoft\Router\Dispatcher\DispatcherAwareTrait which is incompatible with the type-hinted return Yiisoft\Router\Dispatcher\DispatcherAwareInterface.
Loading history...
21
    }
22
}
23