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

DispatcherAwareTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 14
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A withDispatcher() 0 5 1
A getDispatcher() 0 3 1
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