| Conditions | 3 |
| Paths | 3 |
| Total Lines | 21 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | 399 | public function apply($code, MockConfiguration $config) |
|
| 28 | { |
||
| 29 | 399 | foreach ($config->getTargetInterfaces() as $i) { |
|
|
|
|||
| 30 | 20 | $name = ltrim($i->getName(), "\\"); |
|
| 31 | 20 | if (!interface_exists($name)) { |
|
| 32 | 2 | \Mockery::declareInterface($name); |
|
| 33 | 2 | } |
|
| 34 | 399 | } |
|
| 35 | |||
| 36 | 399 | $interfaces = array_reduce((array) $config->getTargetInterfaces(), function ($code, $i) { |
|
| 37 | 20 | return $code . ", \\" . ltrim($i->getName(), "\\"); |
|
| 38 | 399 | }, ""); |
|
| 39 | |||
| 40 | 399 | $code = str_replace( |
|
| 41 | 399 | "implements MockInterface", |
|
| 42 | 399 | "implements MockInterface" . $interfaces, |
|
| 43 | $code |
||
| 44 | 399 | ); |
|
| 45 | |||
| 46 | 399 | return $code; |
|
| 47 | } |
||
| 48 | } |
||
| 49 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.