TransportAwareTrait   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
c 0
b 0
f 0
lcom 0
cbo 0
dl 0
loc 15
ccs 0
cts 4
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A setTransport() 0 4 1
1
<?php
2
/**
3
 * @author Jean Silva <[email protected]>
4
 * @license MIT
5
 */
6
namespace Jeancsil\FlightSpy\Api\Http;
7
8
trait TransportAwareTrait
9
{
10
    /**
11
     * @var Transport
12
     */
13
    private $transport;
14
15
    /**
16
     * @param TransportInterface $transport
17
     */
18
    public function setTransport(TransportInterface $transport)
19
    {
20
        $this->transport = $transport;
0 ignored issues
show
Documentation Bug introduced by
$transport is of type object<Jeancsil\FlightSp...ttp\TransportInterface>, but the property $transport was declared to be of type object<Jeancsil\FlightSpy\Api\Http\Transport>. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
21
    }
22
}
23