Barcode::getRatio()   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 0
dl 0
loc 3
ccs 0
cts 3
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\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\PositionAware;
21
22
final class Barcode implements Command
23
{
24
    use Alignable;
25
    use Rotatable;
26
    use PositionAware;
27
28
    /** @var string */
29
    private $data;
30
31
    /** @var string */
32
    private $type;
33
34
    /** @var int|null */
35
    private $height;
36
37
    /** @var int|null */
38
    private $magnification;
39
40
    /** @var array */
41
    private $ratio = ['narrow' => 1, 'wide' => 1];
42
43
    /** @var bool */
44
    private $readable = false;
45
46
    public function __construct(int $x, int $y, string $data, string $type)
47
    {
48
        $this->x = $x;
49
        $this->y = $y;
50
        $this->data = $data;
51
        $this->type = $type;
52
    }
53
54
    public function height(int $value)
55
    {
56
        $this->height = $value;
57
58
        return $this;
59
    }
60
61
    public function magnify(int $value)
62
    {
63
        $this->magnification = $value;
64
65
        return $this;
66
    }
67
68
    public function ratio(int $narrow, int $wide)
69
    {
70
        $this->ratio = \compact('narrow', 'wide');
71
72
        return $this;
73
    }
74
75
    public function readable(bool $readable = true)
76
    {
77
        $this->readable = $readable;
78
79
        return $this;
80
    }
81
    public function getType(): string
82
    {
83
        return $this->type;
84
    }
85
86
    public function getData(): string
87
    {
88
        return $this->data;
89
    }
90
91
    public function getHeight(): ?int
92
    {
93
        return $this->height;
94
    }
95
96
    public function getMagnification(): ?int
97
    {
98
        return $this->magnification;
99
    }
100
101
    public function getRatio(): array
102
    {
103
        return $this->ratio;
104
    }
105
106
    public function isReadable(): bool
107
    {
108
        return $this->readable;
109
    }
110
}
111