AddressAwareTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 19
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A setAddress() 0 10 2
1
<?php
2
namespace Germania\Addresses;
3
4
trait AddressAwareTrait
5
{
6
    use AddressProviderTrait;
7
8
9
    /**
10
     * @param AddressProviderInterface|null $address
11
     */
12 4
    public function setAddress(?AddressProviderInterface $address)
13
    {
14 4
        if ($address instanceof AddressInterface):
15 2
            $this->address = $address; 
16
        else:
17 2
            $this->address = $address->getAddress();
0 ignored issues
show
Bug introduced by
It seems like $address is not always an object, but can also be of type null. Maybe add an additional type check?

If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe:

function someFunction(A $objectMaybe = null)
{
    if ($objectMaybe instanceof A) {
        $objectMaybe->doSomething();
    }
}
Loading history...
18
        endif;
19
20 4
        return $this;
21
    }
22
}
23