Line.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 Line
  12. {
  13. public const ADDED = 1;
  14. public const REMOVED = 2;
  15. public const UNCHANGED = 3;
  16. private int $type;
  17. private string $content;
  18. public function __construct(int $type = self::UNCHANGED, string $content = '')
  19. {
  20. $this->type = $type;
  21. $this->content = $content;
  22. }
  23. public function content(): string
  24. {
  25. return $this->content;
  26. }
  27. public function type(): int
  28. {
  29. return $this->type;
  30. }
  31. public function isAdded(): bool
  32. {
  33. return $this->type === self::ADDED;
  34. }
  35. public function isRemoved(): bool
  36. {
  37. return $this->type === self::REMOVED;
  38. }
  39. public function isUnchanged(): bool
  40. {
  41. return $this->type === self::UNCHANGED;
  42. }
  43. /**
  44. * @deprecated
  45. */
  46. public function getContent(): string
  47. {
  48. return $this->content;
  49. }
  50. /**
  51. * @deprecated
  52. */
  53. public function getType(): int
  54. {
  55. return $this->type;
  56. }
  57. }