1 | <?php |
||
21 | class QrCode implements QrCodeInterface |
||
22 | { |
||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $text; |
||
27 | /** |
||
28 | * @var int |
||
29 | */ |
||
30 | protected $size = 300; |
||
31 | /** |
||
32 | * @var int |
||
33 | */ |
||
34 | protected $margin = 10; |
||
35 | /** |
||
36 | * @var array |
||
37 | */ |
||
38 | protected $foregroundColor = [ |
||
39 | 'r' => 0, |
||
40 | 'g' => 0, |
||
41 | 'b' => 0 |
||
42 | ]; |
||
43 | /** |
||
44 | * @var array |
||
45 | */ |
||
46 | protected $backgroundColor = [ |
||
47 | 'r' => 255, |
||
48 | 'g' => 255, |
||
49 | 'b' => 255 |
||
50 | ]; |
||
51 | /** |
||
52 | * @var string |
||
53 | */ |
||
54 | protected $encoding = 'UTF-8'; |
||
55 | /** |
||
56 | * @var string ErrorCorrectionLevelInterface value |
||
57 | */ |
||
58 | protected $errorCorrectionLevel; |
||
59 | /** |
||
60 | * @var string |
||
61 | */ |
||
62 | protected $logoPath; |
||
63 | /** |
||
64 | * @var int |
||
65 | */ |
||
66 | protected $logoWidth; |
||
67 | /** |
||
68 | * @var LabelInterface |
||
69 | */ |
||
70 | protected $label; |
||
71 | /** |
||
72 | * @var WriterInterface |
||
73 | */ |
||
74 | protected $writer; |
||
75 | |||
76 | /** |
||
77 | * QrCode constructor. |
||
78 | * |
||
79 | * @param string|null $text |
||
80 | * @param string|null $errorCorrectionLevel |
||
81 | * @param WriterInterface|null $writer |
||
82 | */ |
||
83 | public function __construct(string $text, string $errorCorrectionLevel = null, WriterInterface $writer = null) |
||
89 | |||
90 | /** |
||
91 | * @param int $red |
||
92 | * @param int $green |
||
93 | * @param int $blue |
||
94 | * |
||
95 | * @return $this |
||
96 | */ |
||
97 | public function setForegroundColor(int $red, int $green, int $blue): self |
||
107 | |||
108 | /** |
||
109 | * @param int $red |
||
110 | * @param int $green |
||
111 | * @param int $blue |
||
112 | * |
||
113 | * @return $this |
||
114 | */ |
||
115 | public function setBackgroundColor(int $red, int $green, int $blue): self |
||
125 | |||
126 | /** |
||
127 | * @param string $path |
||
128 | * |
||
129 | * @return $this |
||
130 | * @throws InvalidPathException |
||
131 | */ |
||
132 | public function setLogo(string $path): self |
||
142 | |||
143 | /** |
||
144 | * @param string $encoding |
||
145 | * |
||
146 | * @return $this |
||
147 | */ |
||
148 | public function setEncoding(string $encoding): self |
||
154 | |||
155 | /** |
||
156 | * @param WriterInterface $writer |
||
157 | * |
||
158 | * @return $this |
||
159 | */ |
||
160 | public function setWriter(WriterInterface $writer): self |
||
166 | |||
167 | /** |
||
168 | * @param string $errorCorrectionLevel |
||
169 | * |
||
170 | * @return $this |
||
171 | */ |
||
172 | public function setErrorCorrectionLevel(string $errorCorrectionLevel): self |
||
178 | |||
179 | /** |
||
180 | * @param string $text |
||
181 | * |
||
182 | * @return $this |
||
183 | */ |
||
184 | public function setText(string $text): self |
||
190 | |||
191 | /** |
||
192 | * @param int $size |
||
193 | * |
||
194 | * @return $this |
||
195 | */ |
||
196 | public function setSize(int $size): self |
||
202 | |||
203 | /** |
||
204 | * @param int $margin |
||
205 | * |
||
206 | * @return $this |
||
207 | */ |
||
208 | public function setMargin(int $margin): self |
||
214 | |||
215 | /** |
||
216 | * @param int $width |
||
217 | * |
||
218 | * @return $this |
||
219 | */ |
||
220 | public function setLogoWidth(int $width): self |
||
226 | |||
227 | /** |
||
228 | * @param LabelInterface|string $label |
||
229 | * |
||
230 | * @return $this |
||
231 | */ |
||
232 | public function setLabel($label): self |
||
238 | |||
239 | /** |
||
240 | * @inheritdoc |
||
241 | */ |
||
242 | public function getText(): ?string |
||
246 | |||
247 | /** |
||
248 | * @inheritdoc |
||
249 | */ |
||
250 | public function getSize(): int |
||
254 | |||
255 | /** |
||
256 | * @inheritdoc |
||
257 | */ |
||
258 | public function getMargin(): int |
||
262 | |||
263 | /** |
||
264 | * @inheritdoc |
||
265 | */ |
||
266 | public function getForegroundColor(): array |
||
270 | |||
271 | /** |
||
272 | * @inheritdoc |
||
273 | */ |
||
274 | public function getBackgroundColor(): array |
||
278 | |||
279 | /** |
||
280 | * @inheritdoc |
||
281 | */ |
||
282 | public function getEncoding(): string |
||
286 | |||
287 | /** |
||
288 | * @inheritdoc |
||
289 | */ |
||
290 | public function getErrorCorrectionLevel(): string |
||
294 | |||
295 | /** |
||
296 | * @inheritdoc |
||
297 | */ |
||
298 | public function getLogoPath(): ?string |
||
302 | |||
303 | /** |
||
304 | * @inheritdoc |
||
305 | */ |
||
306 | public function getLogoWidth(): ?int |
||
310 | |||
311 | /** |
||
312 | * @inheritdoc |
||
313 | */ |
||
314 | public function getLabel(): ?LabelInterface |
||
318 | |||
319 | /** |
||
320 | * @return string |
||
321 | */ |
||
322 | public function getContentType(): string |
||
326 | |||
327 | /** |
||
328 | * @throws Exception\ValidationException |
||
329 | * @throws Exception\BadMethodCallException |
||
330 | * @return string |
||
331 | */ |
||
332 | public function writeString(): string |
||
336 | |||
337 | /** |
||
338 | * @return string |
||
339 | */ |
||
340 | public function writeDataUri(): string |
||
344 | |||
345 | /** |
||
346 | * @param string $path |
||
347 | * |
||
348 | * @return bool|int |
||
349 | */ |
||
350 | public function writeFile(string $path) |
||
354 | } |
||
355 |