1 | <?php |
||
17 | trait QROptionsTrait{ |
||
18 | |||
19 | /** |
||
20 | * QR Code version number |
||
21 | * |
||
22 | * [1 ... 40] or QRCode::VERSION_AUTO |
||
23 | * |
||
24 | * @var int |
||
25 | */ |
||
26 | protected $version = QRCode::VERSION_AUTO; |
||
27 | |||
28 | /** |
||
29 | * Minimum QR version (if $version = QRCode::VERSION_AUTO) |
||
30 | * |
||
31 | * @var int |
||
32 | */ |
||
33 | protected $versionMin = 1; |
||
34 | |||
35 | /** |
||
36 | * Maximum QR version |
||
37 | * |
||
38 | * @var int |
||
39 | */ |
||
40 | protected $versionMax = 40; |
||
41 | |||
42 | /** |
||
43 | * Error correct level |
||
44 | * |
||
45 | * QRCode::ECC_X where X is |
||
46 | * L => 7% |
||
47 | * M => 15% |
||
48 | * Q => 25% |
||
49 | * H => 30% |
||
50 | * |
||
51 | * @var int |
||
52 | */ |
||
53 | protected $eccLevel = QRCode::ECC_L; |
||
54 | |||
55 | /** |
||
56 | * Mask Pattern to use |
||
57 | * |
||
58 | * [0...7] or QRCode::MASK_PATTERN_AUTO |
||
59 | * |
||
60 | * @var int |
||
61 | */ |
||
62 | protected $maskPattern = QRCode::MASK_PATTERN_AUTO; |
||
63 | |||
64 | /** |
||
65 | * Add a "quiet zone" (margin) according to the QR code spec |
||
66 | * |
||
67 | * @var bool |
||
68 | */ |
||
69 | protected $addQuietzone = true; |
||
70 | |||
71 | /** |
||
72 | * Size of the quiet zone |
||
73 | * |
||
74 | * internally clamped to [0 ... $moduleCount / 2], defaults to 4 modules |
||
75 | * |
||
76 | * @var int |
||
77 | */ |
||
78 | protected $quietzoneSize = 4; |
||
79 | |||
80 | /** |
||
81 | * Use this to circumvent the data mode detection and force the usage of the given mode. |
||
82 | * valid modes are: Number, AlphaNum, Kanji, Byte |
||
83 | * |
||
84 | * @see https://github.com/chillerlan/php-qrcode/issues/39 |
||
85 | * |
||
86 | * @var string|null |
||
87 | */ |
||
88 | protected $dataMode = null; |
||
89 | |||
90 | /** |
||
91 | * QRCode::OUTPUT_MARKUP_XXXX where XXXX = HTML, SVG |
||
92 | * QRCode::OUTPUT_IMAGE_XXX where XXX = PNG, GIF, JPG |
||
93 | * QRCode::OUTPUT_STRING_XXXX where XXXX = TEXT, JSON |
||
94 | * QRCode::OUTPUT_CUSTOM |
||
95 | * |
||
96 | * @var string |
||
97 | */ |
||
98 | protected $outputType = QRCode::OUTPUT_IMAGE_PNG; |
||
99 | |||
100 | /** |
||
101 | * the FQCN of the custom QROutputInterface if $outputType is set to QRCode::OUTPUT_CUSTOM |
||
102 | * |
||
103 | * @var string|null |
||
104 | */ |
||
105 | protected $outputInterface = null; |
||
106 | |||
107 | /** |
||
108 | * /path/to/cache.file |
||
109 | * |
||
110 | * @var string|null |
||
111 | */ |
||
112 | protected $cachefile = null; |
||
113 | |||
114 | /** |
||
115 | * newline string [HTML, SVG, TEXT] |
||
116 | * |
||
117 | * @var string |
||
118 | */ |
||
119 | protected $eol = PHP_EOL; |
||
120 | |||
121 | /** |
||
122 | * size of a QR code pixel [SVG, IMAGE_*] |
||
123 | * HTML -> via CSS |
||
124 | * |
||
125 | * @var int |
||
126 | */ |
||
127 | protected $scale = 5; |
||
128 | |||
129 | /** |
||
130 | * a common css class |
||
131 | * |
||
132 | * @var string |
||
133 | */ |
||
134 | protected $cssClass = ''; |
||
135 | |||
136 | /** |
||
137 | * SVG opacity |
||
138 | * |
||
139 | * @var float |
||
140 | */ |
||
141 | protected $svgOpacity = 1.0; |
||
142 | |||
143 | /** |
||
144 | * anything between <defs> |
||
145 | * |
||
146 | * @see https://developer.mozilla.org/docs/Web/SVG/Element/defs |
||
147 | * |
||
148 | * @var string |
||
149 | */ |
||
150 | protected $svgDefs = '<style>rect{shape-rendering:crispEdges}</style>'; |
||
151 | |||
152 | /** |
||
153 | * SVG viewBox size. a single integer number which defines width/height of the viewBox attribute. |
||
154 | * |
||
155 | * viewBox="0 0 x x" |
||
156 | * |
||
157 | * @see https://css-tricks.com/scale-svg/#article-header-id-3 |
||
158 | * |
||
159 | * @var int|null |
||
160 | */ |
||
161 | protected $svgViewBoxSize = null; |
||
162 | |||
163 | /** |
||
164 | * string substitute for dark |
||
165 | * |
||
166 | * @var string |
||
167 | */ |
||
168 | protected $textDark = '🔴'; |
||
169 | |||
170 | /** |
||
171 | * string substitute for light |
||
172 | * |
||
173 | * @var string |
||
174 | */ |
||
175 | protected $textLight = '⭕'; |
||
176 | |||
177 | /** |
||
178 | * markup substitute for dark (CSS value) |
||
179 | * |
||
180 | * @var string |
||
181 | */ |
||
182 | protected $markupDark = '#000'; |
||
183 | |||
184 | /** |
||
185 | * markup substitute for light (CSS value) |
||
186 | * |
||
187 | * @var string |
||
188 | */ |
||
189 | protected $markupLight = '#fff'; |
||
190 | |||
191 | /** |
||
192 | * toggle base64 or raw image data |
||
193 | * |
||
194 | * @var bool |
||
195 | */ |
||
196 | protected $imageBase64 = true; |
||
197 | |||
198 | /** |
||
199 | * toggle transparency, not supported by jpg |
||
200 | * |
||
201 | * @var bool |
||
202 | */ |
||
203 | protected $imageTransparent = true; |
||
204 | |||
205 | /** |
||
206 | * @see imagecolortransparent() |
||
207 | * |
||
208 | * @var array [R, G, B] |
||
209 | */ |
||
210 | protected $imageTransparencyBG = [255, 255, 255]; |
||
211 | |||
212 | /** |
||
213 | * @see imagepng() |
||
214 | * |
||
215 | * @var int |
||
216 | */ |
||
217 | protected $pngCompression = -1; |
||
218 | |||
219 | /** |
||
220 | * @see imagejpeg() |
||
221 | * |
||
222 | * @var int |
||
223 | */ |
||
224 | protected $jpegQuality = 85; |
||
225 | |||
226 | /** |
||
227 | * Imagick output format |
||
228 | * |
||
229 | * @see Imagick::setType() |
||
230 | * |
||
231 | * @var string |
||
232 | */ |
||
233 | protected $imagickFormat = 'png'; |
||
234 | |||
235 | /** |
||
236 | * Imagick background color (defaults to "transparent") |
||
237 | * |
||
238 | * @see \ImagickPixel::__construct() |
||
239 | * |
||
240 | * @var string|null |
||
241 | */ |
||
242 | protected $imagickBG = null; |
||
243 | |||
244 | /** |
||
245 | * Measurement unit for FPDF output: pt, mm, cm, in (defaults to "pt") |
||
246 | * |
||
247 | * @see \FPDF::__construct() |
||
248 | */ |
||
249 | protected $fpdfMeasureUnit = 'pt'; |
||
250 | |||
251 | /** |
||
252 | * Module values map |
||
253 | * |
||
254 | * HTML, IMAGICK: #ABCDEF, cssname, rgb(), rgba()... |
||
255 | * IMAGE: [63, 127, 255] // R, G, B |
||
256 | * |
||
257 | * @var array|null |
||
258 | */ |
||
259 | protected $moduleValues = null; |
||
260 | |||
261 | /** |
||
262 | * clamp min/max version number |
||
263 | * |
||
264 | * @param int $versionMin |
||
265 | * @param int $versionMax |
||
266 | * |
||
267 | * @return void |
||
268 | */ |
||
269 | protected function setMinMaxVersion(int $versionMin, int $versionMax):void{ |
||
276 | |||
277 | /** |
||
278 | * sets the minimum version number |
||
279 | * |
||
280 | * @param int $version |
||
281 | * |
||
282 | * @return void |
||
283 | */ |
||
284 | protected function set_versionMin(int $version):void{ |
||
287 | |||
288 | /** |
||
289 | * sets the maximum version number |
||
290 | * |
||
291 | * @param int $version |
||
292 | * |
||
293 | * @return void |
||
294 | */ |
||
295 | protected function set_versionMax(int $version):void{ |
||
298 | |||
299 | /** |
||
300 | * sets the error correction level |
||
301 | * |
||
302 | * @param int $eccLevel |
||
303 | * |
||
304 | * @return void |
||
305 | * @throws \chillerlan\QRCode\QRCodeException |
||
306 | */ |
||
307 | protected function set_eccLevel(int $eccLevel):void{ |
||
315 | |||
316 | /** |
||
317 | * sets/clamps the mask pattern |
||
318 | * |
||
319 | * @param int $maskPattern |
||
320 | * |
||
321 | * @return void |
||
322 | */ |
||
323 | protected function set_maskPattern(int $maskPattern):void{ |
||
330 | |||
331 | /** |
||
332 | * sets the transparency background color |
||
333 | * |
||
334 | * @param mixed $imageTransparencyBG |
||
335 | * |
||
336 | * @return void |
||
337 | * @throws \chillerlan\QRCode\QRCodeException |
||
338 | */ |
||
339 | protected function set_imageTransparencyBG($imageTransparencyBG):void{ |
||
361 | |||
362 | /** |
||
363 | * sets/clamps the version number |
||
364 | * |
||
365 | * @param int $version |
||
366 | * |
||
367 | * @return void |
||
368 | */ |
||
369 | protected function set_version(int $version):void{ |
||
376 | |||
377 | /** |
||
378 | * sets the FPDF measurement unit |
||
379 | * |
||
380 | * @codeCoverageIgnore |
||
381 | */ |
||
382 | protected function set_fpdfMeasureUnit(string $unit):void{ |
||
391 | |||
392 | } |
||
393 |