Output::getLine()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 4
cts 4
cp 1
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
crap 2
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