Bitmap   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 52
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 52
ccs 0
cts 30
cp 0
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getCanvas() 0 3 1
A getOverlay() 0 3 1
A getWidth() 0 3 1
A overlay() 0 5 1
A getHeight() 0 3 1
A __construct() 0 10 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\PositionAware;
19
20
final class Bitmap implements Command
21
{
22
    use PositionAware;
23
24
    private $canvas;
25
26
    /** @var bool */
27
    private $overlay;
28
29
    /** @var int */
30
    private $width;
31
32
    /** @var int */
33
    private $height;
34
35
    public function __construct(int $x, int $y, \Imagick $canvas)
36
    {
37
        $this->x = $x;
38
        $this->y = $y;
39
        $this->canvas = clone $canvas;
40
        $this->width = $this->canvas->getImageWidth();
41
        $this->height = $this->canvas->getImageHeight();
42
43
        $this->canvas->setImageType(\Imagick::IMGTYPE_TRUECOLOR);
44
        $this->canvas->thresholdImage(.5 * \Imagick::getQuantumRange()['quantumRangeLong']);
45
    }
46
47
    public function overlay($value)
48
    {
49
        $this->overlay = $value;
50
51
        return $this;
52
    }
53
54
    public function getOverlay()
55
    {
56
        return $this->overlay;
57
    }
58
59
    public function getCanvas()
60
    {
61
        return $this->canvas;
62
    }
63
64
    public function getWidth(): int
65
    {
66
        return $this->width;
67
    }
68
69
    public function getHeight(): int
70
    {
71
        return $this->height;
72
    }
73
}
74