Debian Codegraph @

vendor/endroid/qr-code/src/QrCode.php

raw
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Endroid\QrCode;
6
7 use Endroid\QrCode\Color\Color;
8 use Endroid\QrCode\Color\ColorInterface;
9 use Endroid\QrCode\Encoding\Encoding;
10 use Endroid\QrCode\Encoding\EncodingInterface;
11
12 final class QrCode implements QrCodeInterface
13 {
14 public function __construct(
15 private string $data,
16 private EncodingInterface $encoding = new Encoding('UTF-8'),
17 private ErrorCorrectionLevel $errorCorrectionLevel = ErrorCorrectionLevel::Low,
18 private int $size = 300,
19 private int $margin = 10,
20 private RoundBlockSizeMode $roundBlockSizeMode = RoundBlockSizeMode::Margin,
21 private ColorInterface $foregroundColor = new Color(0, 0, 0),
22 private ColorInterface $backgroundColor = new Color(255, 255, 255)
23 ) {
24 }
25
26 public static function create(string $data): self
27 {
28 return new self($data);
29 }
30
31 public function getData(): string
32 {
33 return $this->data;
34 }
35
36 public function setData(string $data): self
37 {
38 $this->data = $data;
39
40 return $this;
41 }
42
43 public function getEncoding(): EncodingInterface
44 {
45 return $this->encoding;
46 }
47
48 public function setEncoding(Encoding $encoding): self
49 {
50 $this->encoding = $encoding;
51
52 return $this;
53 }
54
55 public function getErrorCorrectionLevel(): ErrorCorrectionLevel
56 {
57 return $this->errorCorrectionLevel;
58 }
59
60 public function setErrorCorrectionLevel(ErrorCorrectionLevel $errorCorrectionLevel): self
61 {
62 $this->errorCorrectionLevel = $errorCorrectionLevel;
63
64 return $this;
65 }
66
67 public function getSize(): int
68 {
69 return $this->size;
70 }
71
72 public function setSize(int $size): self
73 {
74 $this->size = $size;
75
76 return $this;
77 }
78
79 public function getMargin(): int
80 {
81 return $this->margin;
82 }
83
84 public function setMargin(int $margin): self
85 {
86 $this->margin = $margin;
87
88 return $this;
89 }
90
91 public function getRoundBlockSizeMode(): RoundBlockSizeMode
92 {
93 return $this->roundBlockSizeMode;
94 }
95
96 public function setRoundBlockSizeMode(RoundBlockSizeMode $roundBlockSizeMode): self
97 {
98 $this->roundBlockSizeMode = $roundBlockSizeMode;
99
100 return $this;
101 }
102
103 public function getForegroundColor(): ColorInterface
104 {
105 return $this->foregroundColor;
106 }
107
108 public function setForegroundColor(ColorInterface $foregroundColor): self
109 {
110 $this->foregroundColor = $foregroundColor;
111
112 return $this;
113 }
114
115 public function getBackgroundColor(): ColorInterface
116 {
117 return $this->backgroundColor;
118 }
119
120 public function setBackgroundColor(ColorInterface $backgroundColor): self
121 {
122 $this->backgroundColor = $backgroundColor;
123
124 return $this;
125 }
126 }