Output::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php declare(strict_types=1);
2
3
namespace Gitilicious\GitClient\Cli\Output;
4
5
class Output
6
{
7
    private $lines = [];
8
9 24
    public function __construct(string $output)
10
    {
11 24
        $this->lines = explode(PHP_EOL, trim($output));
12 24
    }
13
14 2
    public function getNumberOfLines(): int
15
    {
16 2
        return count($this->lines);
17
    }
18
19 7
    public function getLine(int $lineNumber): string
20
    {
21 7
        if (!array_key_exists($lineNumber - 1, $this->lines)) {
22
            // @todo or should we throw here instead?
23 1
            return '';
24
        }
25
26 6
        return $this->lines[$lineNumber - 1];
27
    }
28
}
29