| Conditions | 2 |
| Paths | 2 |
| Total Lines | 11 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 17 | public function truncate(): string |
||
| 18 | { |
||
| 19 | $size = \mb_strlen($this->payload); |
||
| 20 | |||
| 21 | if ($size > $this->threshold) { |
||
| 22 | $newPayload = \mb_substr($this->payload, 0, $this->threshold); |
||
| 23 | $truncated = $size - $this->threshold; |
||
| 24 | return \sprintf('%s .. (truncated %d)', $newPayload, $truncated); |
||
| 25 | } |
||
| 26 | |||
| 27 | return $this->payload; |
||
| 28 | } |
||
| 30 |