hanneskod /
readme-tester
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace hanneskod\readmetester\Expectation; |
||
| 6 | |||
| 7 | use hanneskod\readmetester\Runner\OutcomeInterface; |
||
| 8 | |||
| 9 | abstract class AbstractStatus implements StatusInterface |
||
| 10 | { |
||
| 11 | public function __construct( |
||
| 12 | private OutcomeInterface $outcome, |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 13 | private string $content, |
||
| 14 | ) {} |
||
| 15 | |||
| 16 | public function getContent(): string |
||
| 17 | { |
||
| 18 | return $this->content; |
||
| 19 | } |
||
| 20 | |||
| 21 | public function getTruncatedContent(int $strlen = 60): string |
||
| 22 | { |
||
| 23 | $content = trim($this->getContent()); |
||
| 24 | |||
| 25 | if (mb_strlen($content) <= $strlen) { |
||
| 26 | return $content; |
||
| 27 | } |
||
| 28 | |||
| 29 | return mb_substr($content, 0, $strlen - 3) . '...'; |
||
| 30 | } |
||
| 31 | |||
| 32 | public function getOutcome(): OutcomeInterface |
||
| 33 | { |
||
| 34 | return $this->outcome; |
||
| 35 | } |
||
| 36 | } |
||
| 37 |