Conditions | 4 |
Paths | 6 |
Total Lines | 27 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
32 | public function __invoke( $aggregator ) |
||
33 | { |
||
34 | |||
35 | // Default value |
||
36 | if (!isset($aggregator->salesman)): |
||
37 | $aggregator->salesman = null; |
||
38 | endif; |
||
39 | |||
40 | |||
41 | // Prepare using |
||
42 | $salesman_factory = $this->salesman_factory; |
||
43 | |||
44 | |||
45 | // If salesman_id is available |
||
46 | if ($aggregator instanceOf SalesmanIdProviderInterface): |
||
47 | $aggregator->salesman = $salesman_factory( $aggregator->getSalesmanId(), $this->salesman_fallback ); |
||
|
|||
48 | |||
49 | elseif (isset($aggregator->salesman_id)): |
||
50 | $aggregator->salesman = $salesman_factory( $aggregator->salesman_id, $this->salesman_fallback ); |
||
51 | |||
52 | // Salesman can not be set |
||
53 | else: |
||
54 | return false; |
||
55 | endif; |
||
56 | |||
57 | return true; |
||
58 | } |
||
59 | } |
||
60 |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: