Completed
Push — develop ( fe1195...b733eb )
by Alec
05:48
created

CounterReportFormatter::setStyles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 0
dl 0
loc 2
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * User: alec
4
 * Date: 10.12.18
5
 * Time: 14:22
6
 */
7
declare(strict_types=1);
8
9
namespace AlecRabbit\Tools\Reports\Formatters;
10
11
use AlecRabbit\Tools\Reports\CounterReport;
12
use const AlecRabbit\Constants\Accessories\DEFAULT_NAME;
0 ignored issues
show
Bug introduced by
The constant AlecRabbit\Constants\Accessories\DEFAULT_NAME was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
13
14
class CounterReportFormatter extends Formatter
15
{
16
    /** @var CounterReport */
17
    protected $report;
18
19 7
    public function setStyles(): void
20
    {
21 7
    }
22
23 2
    public function getString($colored = true): string
24
    {
25 2
        if (DEFAULT_NAME === $name = $this->report->getName()) {
26 2
            return $this->count();
27
        }
28
        return $this->full($name);
29
    }
30
31
    /**
32
     * @return string
33
     * @throws \Throwable
34
     */
35 2
    public function count(): string
36
    {
37
        return
38 2
            sprintf(
39 2
                'Counter: %s(%s)%s',
40 2
                $this->theme->comment((string)$this->report->getValue()),
41 2
                $this->theme->dark((string)$this->report->getStep()),
42 2
                PHP_EOL
43
            );
44
    }
45
46
    /**
47
     * @param string $name
48
     * @return string
49
     * @throws \Throwable
50
     */
51
    public function full(string $name): string
52
    {
53
        return
54
            sprintf(
55
                'Counter:[%s] Value: %s, Step: %s %s',
56
                $name,
57
                $this->theme->comment((string)$this->report->getValue()),
58
                $this->report->getStep(),
59
                PHP_EOL
60
            );
61
    }
62
}
63