Total Complexity | 4 |
Total Lines | 62 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | class Line |
||
22 | { |
||
23 | /** |
||
24 | * Possible line operations |
||
25 | */ |
||
26 | public const ADDED = 'added'; |
||
27 | public const REMOVED = 'removed'; |
||
28 | public const EXISTED = 'existed'; |
||
29 | |||
30 | /** |
||
31 | * Map diff output to file operation |
||
32 | * @var array |
||
33 | */ |
||
34 | public static $opsMap = [ |
||
35 | '+' => self::ADDED, |
||
36 | '-' => self::REMOVED, |
||
37 | ' ' => self::EXISTED |
||
38 | ]; |
||
39 | |||
40 | /** |
||
41 | * @var string |
||
42 | */ |
||
43 | private $operation; |
||
44 | |||
45 | /** |
||
46 | * @var string |
||
47 | */ |
||
48 | private $content; |
||
49 | |||
50 | /** |
||
51 | * Line constructor. |
||
52 | * |
||
53 | * @param string $operation |
||
54 | 11 | * @param string $content |
|
55 | */ |
||
56 | 11 | public function __construct(string $operation, string $content) |
|
57 | 1 | { |
|
58 | if (!in_array($operation, self::$opsMap)) { |
||
59 | 10 | throw new \RuntimeException('invalid line operation: ' . $operation); |
|
60 | 10 | } |
|
61 | 10 | $this->operation = $operation; |
|
62 | $this->content = $content; |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Operation getter. |
||
67 | * |
||
68 | 4 | * @return string |
|
69 | */ |
||
70 | 4 | public function getOperation(): string |
|
73 | } |
||
74 | |||
75 | /** |
||
76 | * Content getter. |
||
77 | * |
||
78 | 2 | * @return string |
|
79 | */ |
||
80 | 2 | public function getContent(): string |
|
85 |