| Conditions | 5 |
| Paths | 4 |
| Total Lines | 19 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 5 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 55 | 44 | public function generate(ElementInterface $element) |
|
| 56 | { |
||
| 57 | 44 | $value = $this->attachment ?? $this->value; |
|
| 58 | |||
| 59 | 44 | if (is_string($value)) { |
|
| 60 | /** @var T */ |
||
| 61 | 9 | return new $value; |
|
| 62 | } |
||
| 63 | |||
| 64 | 37 | if (is_callable($value)) { |
|
| 65 | 3 | return ($value)($element); |
|
| 66 | } |
||
| 67 | |||
| 68 | // Only clone value if it's not attached |
||
| 69 | 34 | if (!$this->attachment && is_object($value)) { |
|
| 70 | 1 | return clone $value; |
|
| 71 | } |
||
| 72 | |||
| 73 | 33 | return $value; |
|
|
|
|||
| 74 | } |
||
| 76 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: