Passed
Pull Request — master (#47)
by
unknown
11:29
created

AbstractStatus::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 0
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 2
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,
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