Line.php 656 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. declare(strict_types = 1);
  3. namespace BaconQrCode\Renderer\Path;
  4. final class Line implements OperationInterface
  5. {
  6. /**
  7. * @var float
  8. */
  9. private $x;
  10. /**
  11. * @var float
  12. */
  13. private $y;
  14. public function __construct(float $x, float $y)
  15. {
  16. $this->x = $x;
  17. $this->y = $y;
  18. }
  19. public function getX() : float
  20. {
  21. return $this->x;
  22. }
  23. public function getY() : float
  24. {
  25. return $this->y;
  26. }
  27. /**
  28. * @return self
  29. */
  30. public function translate(float $x, float $y) : OperationInterface
  31. {
  32. return new self($this->x + $x, $this->y + $y);
  33. }
  34. }