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

AbstractStatus   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 7
c 1
b 0
f 0
dl 0
loc 26
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getTruncatedContent() 0 9 2
A getContent() 0 3 1
A __construct() 0 4 1
A getOutcome() 0 3 1
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