Debian Codegraph @

src/Renderer/Eye/SquareEye.php

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