Chunk.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php declare(strict_types=1);
  2. /*
  3. * This file is part of sebastian/diff.
  4. *
  5. * (c) Sebastian Bergmann <sebastian@phpunit.de>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace SebastianBergmann\Diff;
  11. final class Chunk
  12. {
  13. /**
  14. * @var int
  15. */
  16. private $start;
  17. /**
  18. * @var int
  19. */
  20. private $startRange;
  21. /**
  22. * @var int
  23. */
  24. private $end;
  25. /**
  26. * @var int
  27. */
  28. private $endRange;
  29. /**
  30. * @var Line[]
  31. */
  32. private $lines;
  33. public function __construct(int $start = 0, int $startRange = 1, int $end = 0, int $endRange = 1, array $lines = [])
  34. {
  35. $this->start = $start;
  36. $this->startRange = $startRange;
  37. $this->end = $end;
  38. $this->endRange = $endRange;
  39. $this->lines = $lines;
  40. }
  41. public function getStart(): int
  42. {
  43. return $this->start;
  44. }
  45. public function getStartRange(): int
  46. {
  47. return $this->startRange;
  48. }
  49. public function getEnd(): int
  50. {
  51. return $this->end;
  52. }
  53. public function getEndRange(): int
  54. {
  55. return $this->endRange;
  56. }
  57. /**
  58. * @return Line[]
  59. */
  60. public function getLines(): array
  61. {
  62. return $this->lines;
  63. }
  64. /**
  65. * @param Line[] $lines
  66. */
  67. public function setLines(array $lines): void
  68. {
  69. foreach ($lines as $line) {
  70. if (!$line instanceof Line) {
  71. throw new InvalidArgumentException;
  72. }
  73. }
  74. $this->lines = $lines;
  75. }
  76. }