Passed
Pull Request — master (#10)
by
unknown
08:23
created

Element::barcode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 4
dl 0
loc 3
rs 10
ccs 0
cts 1
cp 0
crap 2
1
<?php
2
3
/**
4
 * This file is part of PhpAidc LabelPrinter package.
5
 *
6
 * © Appwilio (https://appwilio.com)
7
 * © JhaoDa (https://github.com/jhaoda)
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
declare(strict_types=1);
14
15
namespace PhpAidc\LabelPrinter\Label;
16
17
use PhpAidc\LabelPrinter\Command\Raw;
18
use PhpAidc\LabelPrinter\Command\Clear;
19
use PhpAidc\LabelPrinter\Command\Bitmap;
20
use PhpAidc\LabelPrinter\Command\Barcode;
21
use PhpAidc\LabelPrinter\Command\QRCode;
22
use PhpAidc\LabelPrinter\Command\TextLine;
23
use PhpAidc\LabelPrinter\Command\TextBlock;
24
use PhpAidc\LabelPrinter\Command\ExternalImage;
25
use PhpAidc\LabelPrinter\Command\InternalImage;
26
27
final class Element
28
{
29
    /**
30
     * Sends raw command to the printer.
31
     *
32
     * @param  iterable|string  $data
33
     *
34
     * @return Raw
35 7
     */
36
    public static function raw($data): Raw
37 7
    {
38
        return new Raw($data);
39
    }
40
41
    /**
42
     * Partially or completely clears the print image buffer.
43
     *
44
     * @param  string|null  $field  the field from which the print image buffer
45
     *                              should be cleared (Fingerprint only)
46
     *
47
     * @return Clear
48
     */
49
    public static function clear(?string $field = null): Clear
50
    {
51
        return new Clear($field);
52
    }
53
54
    public static function bitmap(int $x, int $y, \Imagick $canvas): Bitmap
55
    {
56
        return new Bitmap(...\func_get_args());
57
    }
58
59
    /**
60
     * Prints an image from host's filesystem.
61
     *
62
     * @param  int                  $x
63
     * @param  int                  $y
64
     * @param  \SplFileInfo|string  $source
65
     *
66
     * @return ExternalImage
67
     */
68
    public static function extImage(int $x, int $y, $source): ExternalImage
69
    {
70
        return new ExternalImage(...\func_get_args());
71
    }
72
73
    /**
74
     * Prints an image stored in the printer's memory.
75
     *
76
     * @param  int     $x
77
     * @param  int     $y
78
     * @param  string  $name  full name of the image
79
     *
80
     * @return InternalImage
81
     */
82
    public static function intImage(int $x, int $y, string $name): InternalImage
83
    {
84
        return new InternalImage(...\func_get_args());
85
    }
86
87
    public static function barcode(int $x, int $y, string $data, string $type): Barcode
88
    {
89
        return new Barcode(...\func_get_args());
90
    }
91
92
    public static function textLine(int $x, int $y, string $text, string $font, $size = null): TextLine
93
    {
94
        return new TextLine(...\func_get_args());
95
    }
96
97
    public static function textBlock(int $x, int $y, string $text, string $font, float $size = null): TextBlock
98
    {
99
        return new TextBlock(...\func_get_args());
100
    }
101
102
    /**
103
     * Print a qr code in the label
104
     * @param int       $x
105
     * @param int       $y
106
     * @param string    $data
107
     * @param string    $eccLevel   Error correction recovery level (L: 7% / M: 15% / Q: 25% / H: 30%)
108
     * @param int       $cellWidth  Width of a single cell (1~N)
109
     * @param string    $mode       Encode mode (A: auto / M: manual)
110
     */
111
    public static function qrcode(int $x, int $y, string $data, string $eccLevel, int $cellWidth, string $mode): QRCode
112
    {
113
        return new QRCode(...\func_get_args());
114
    }
115
}
116