| Conditions | 4 |
| Paths | 6 |
| Total Lines | 28 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 32 | public function __invoke( $aggregator ) |
||
| 33 | { |
||
| 34 | |||
| 35 | |||
| 36 | // Prepare callable |
||
| 37 | $salesman_factory = $this->salesman_factory; |
||
| 38 | |||
| 39 | |||
| 40 | // Add salesman proporty if not exists |
||
| 41 | if (!isset($aggregator->salesman)): |
||
| 42 | $aggregator->salesman = null; |
||
| 43 | endif; |
||
| 44 | |||
| 45 | |||
| 46 | // If salesman_id is available |
||
| 47 | if ($aggregator instanceOf SalesmanIdProviderInterface): |
||
| 48 | $aggregator->salesman = $salesman_factory( $aggregator->getSalesmanId(), $this->salesman_fallback ); |
||
|
|
|||
| 49 | |||
| 50 | elseif (isset($aggregator->salesman_id)): |
||
| 51 | $aggregator->salesman = $salesman_factory( $aggregator->salesman_id, $this->salesman_fallback ); |
||
| 52 | |||
| 53 | // Salesman can not be set |
||
| 54 | else: |
||
| 55 | return false; |
||
| 56 | endif; |
||
| 57 | |||
| 58 | return true; |
||
| 59 | } |
||
| 60 | } |
||
| 61 |
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: