TextLine   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
c 1
b 0
f 0
dl 0
loc 40
ccs 0
cts 20
cp 0
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getMaxWidth() 0 3 1
A maxWidth() 0 5 1
A getText() 0 3 1
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\Command;
16
17
use PhpAidc\LabelPrinter\Contract\Command;
18
use PhpAidc\LabelPrinter\Command\Concerns\Alignable;
19
use PhpAidc\LabelPrinter\Command\Concerns\Rotatable;
20
use PhpAidc\LabelPrinter\Command\Concerns\FontAware;
21
use PhpAidc\LabelPrinter\Command\Concerns\Invertible;
22
use PhpAidc\LabelPrinter\Command\Concerns\Magnifiable;
23
use PhpAidc\LabelPrinter\Command\Concerns\PositionAware;
24
use PhpAidc\LabelPrinter\Command\Concerns\ImageFallback;
25
26
final class TextLine implements Command
27
{
28
    use Alignable;
29
    use FontAware;
30
    use Rotatable;
31
    use Invertible;
32
    use Magnifiable;
33
    use ImageFallback;
34
    use PositionAware;
35
36
    /** @var string */
37
    private $text;
38
39
    /** @var int|null */
40
    private $maxWidth;
41
42
    public function __construct(int $x, int $y, string $text, string $font, $size = null)
43
    {
44
        $this->x = $x;
45
        $this->y = $y;
46
        $this->text = $text;
47
        $this->fontName = $font;
48
        $this->fontSize = $size;
49
    }
50
51
    public function maxWidth(int $value)
52
    {
53
        $this->maxWidth = $value;
54
55
        return $this;
56
    }
57
58
    public function getText(): string
59
    {
60
        return $this->text;
61
    }
62
63
    public function getMaxWidth(): ?int
64
    {
65
        return $this->maxWidth;
66
    }
67
}
68