| Total Complexity | 12 |
| Total Lines | 72 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | class LineMutation |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * @var LineNumber|null |
||
| 21 | */ |
||
| 22 | private $newLine; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var LineNumber|null |
||
| 26 | */ |
||
| 27 | private $originalLine; |
||
| 28 | |||
| 29 | public static function originalLineNumber(LineNumber $lineNumber): self |
||
| 30 | { |
||
| 31 | return new self($lineNumber, null); |
||
| 32 | } |
||
| 33 | |||
| 34 | public static function newLineNumber(LineNumber $lineNumber): self |
||
| 35 | { |
||
| 36 | return new self(null, $lineNumber); |
||
| 37 | } |
||
| 38 | |||
| 39 | private function __construct(?LineNumber $originalLine, ?LineNumber $newLine) |
||
| 43 | } |
||
| 44 | |||
| 45 | public function getNewLine(): ?LineNumber |
||
| 48 | } |
||
| 49 | |||
| 50 | public function getOriginalLine(): ?LineNumber |
||
| 51 | { |
||
| 52 | return $this->originalLine; |
||
| 53 | } |
||
| 54 | |||
| 55 | public function isAdded(): bool |
||
| 56 | { |
||
| 57 | return null !== $this->newLine; |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * Returns true if other LineMutation is the same. |
||
| 62 | * |
||
| 63 | * @param LineMutation|null $other |
||
| 64 | */ |
||
| 65 | public function isEqual(?self $other): bool |
||
| 66 | { |
||
| 67 | if (null === $other) { |
||
| 68 | return false; |
||
| 69 | } |
||
| 70 | |||
| 71 | if (!$this->isLineNumberEqual($this->newLine, $other->newLine)) { |
||
| 72 | return false; |
||
| 73 | } |
||
| 74 | |||
| 75 | return $this->isLineNumberEqual($this->originalLine, $other->originalLine); |
||
| 76 | } |
||
| 77 | |||
| 78 | private function isLineNumberEqual(?LineNumber $a, ?LineNumber $b): bool |
||
| 89 | } |
||
| 90 | } |
||
| 91 |