Element::textBlock()   A
last analyzed

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 5
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
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\TextLine;
22
use PhpAidc\LabelPrinter\Command\TextBlock;
23
use PhpAidc\LabelPrinter\Command\ExternalImage;
24
use PhpAidc\LabelPrinter\Command\InternalImage;
25
26
final class Element
27
{
28
    /**
29
     * Sends raw command to the printer.
30
     *
31
     * @param  iterable|string  $data
32
     *
33
     * @return Raw
34
     */
35 7
    public static function raw($data): Raw
36
    {
37 7
        return new Raw($data);
38
    }
39
40
    /**
41
     * Partially or completely clears the print image buffer.
42
     *
43
     * @param  string|null  $field  the field from which the print image buffer
44
     *                              should be cleared (Fingerprint only)
45
     *
46
     * @return Clear
47
     */
48
    public static function clear(?string $field = null): Clear
49
    {
50
        return new Clear($field);
51
    }
52
53
    public static function bitmap(int $x, int $y, \Imagick $canvas): Bitmap
54
    {
55
        return new Bitmap(...\func_get_args());
56
    }
57
58
    /**
59
     * Prints an image from host's filesystem.
60
     *
61
     * @param  int                  $x
62
     * @param  int                  $y
63
     * @param  \SplFileInfo|string  $source
64
     *
65
     * @return ExternalImage
66
     */
67
    public static function extImage(int $x, int $y, $source): ExternalImage
68
    {
69
        return new ExternalImage(...\func_get_args());
70
    }
71
72
    /**
73
     * Prints an image stored in the printer's memory.
74
     *
75
     * @param  int     $x
76
     * @param  int     $y
77
     * @param  string  $name  full name of the image
78
     *
79
     * @return InternalImage
80
     */
81
    public static function intImage(int $x, int $y, string $name): InternalImage
82
    {
83
        return new InternalImage(...\func_get_args());
84
    }
85
86
    public static function barcode(int $x, int $y, string $data, string $type): Barcode
87
    {
88
        return new Barcode(...\func_get_args());
89
    }
90
91
    public static function textLine(int $x, int $y, string $text, string $font, $size = null): TextLine
92
    {
93
        return new TextLine(...\func_get_args());
94
    }
95
96
    public static function textBlock(int $x, int $y, string $text, string $font, float $size = null): TextBlock
97
    {
98
        return new TextBlock(...\func_get_args());
99
    }
100
}
101