Conditions | 2 |
Paths | 2 |
Total Lines | 11 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Tests | 4 |
CRAP Score | 2.3149 |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
17 | 1 | public function truncate(): string |
|
18 | { |
||
19 | 1 | $size = \mb_strlen($this->payload); |
|
20 | |||
21 | 1 | 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 | 1 | return $this->payload; |
|
28 | } |
||
30 |