SquareEye.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. declare(strict_types = 1);
  3. namespace BaconQrCode\Renderer\Eye;
  4. use BaconQrCode\Renderer\Path\Path;
  5. /**
  6. * Renders the eyes in their default square shape.
  7. */
  8. final class SquareEye implements EyeInterface
  9. {
  10. /**
  11. * @var self|null
  12. */
  13. private static $instance;
  14. private function __construct()
  15. {
  16. }
  17. public static function instance() : self
  18. {
  19. return self::$instance ?: self::$instance = new self();
  20. }
  21. public function getExternalPath() : Path
  22. {
  23. return (new Path())
  24. ->move(-3.5, -3.5)
  25. ->line(3.5, -3.5)
  26. ->line(3.5, 3.5)
  27. ->line(-3.5, 3.5)
  28. ->close()
  29. ->move(-2.5, -2.5)
  30. ->line(-2.5, 2.5)
  31. ->line(2.5, 2.5)
  32. ->line(2.5, -2.5)
  33. ->close()
  34. ;
  35. }
  36. public function getInternalPath() : Path
  37. {
  38. return (new Path())
  39. ->move(-1.5, -1.5)
  40. ->line(1.5, -1.5)
  41. ->line(1.5, 1.5)
  42. ->line(-1.5, 1.5)
  43. ->close()
  44. ;
  45. }
  46. }