| Total Complexity | 12 |
| Total Lines | 60 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | final class LineMutation |
||
| 18 | { |
||
| 19 | public static function originalLineNumber(LineNumber $lineNumber): self |
||
| 20 | { |
||
| 21 | return new self($lineNumber, null); |
||
| 22 | } |
||
| 23 | |||
| 24 | public static function newLineNumber(LineNumber $lineNumber): self |
||
| 25 | { |
||
| 26 | return new self(null, $lineNumber); |
||
| 27 | } |
||
| 28 | |||
| 29 | private function __construct( |
||
| 33 | } |
||
| 34 | |||
| 35 | public function getNewLine(): ?LineNumber |
||
| 38 | } |
||
| 39 | |||
| 40 | public function getOriginalLine(): ?LineNumber |
||
| 41 | { |
||
| 42 | return $this->originalLine; |
||
| 43 | } |
||
| 44 | |||
| 45 | public function isAdded(): bool |
||
| 46 | { |
||
| 47 | return null !== $this->newLine; |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Returns true if other LineMutation is the same. |
||
| 52 | */ |
||
| 53 | public function isEqual(?self $other): bool |
||
| 54 | { |
||
| 55 | if (null === $other) { |
||
| 56 | return false; |
||
| 57 | } |
||
| 58 | |||
| 59 | if (!$this->isLineNumberEqual($this->newLine, $other->newLine)) { |
||
| 60 | return false; |
||
| 61 | } |
||
| 62 | |||
| 63 | return $this->isLineNumberEqual($this->originalLine, $other->originalLine); |
||
| 64 | } |
||
| 65 | |||
| 66 | private function isLineNumberEqual(?LineNumber $a, ?LineNumber $b): bool |
||
| 77 | } |
||
| 78 | } |
||
| 79 |