EmulateText   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 25
ccs 0
cts 13
cp 0
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A emulate() 0 15 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\Emulation;
16
17
use PhpAidc\LabelPrinter\Command\TextLine;
18
use PhpAidc\LabelPrinter\Command\TextBlock;
19
20
trait EmulateText
21
{
22
    /**
23
     * @param  TextLine|TextBlock  $command
24
     * @param  int|null            $width
25
     * @param  int|null            $height
26
     * @param  int|null            $spacing
27
     *
28
     * @return \Imagick
29
     */
30
    private function emulate($command, ?int $width = null, ?int $height = null, ?int $spacing = null): \Imagick
31
    {
32
        $canvas = new Canvas($width, $height);
33
34
        $canvas->write(
35
            $command->getText(),
36
            $command->getFontName(),
37
            (float) $command->getFontSize(),
38
            $command->getRotation(),
39
            $command->getAnchor(),
40
            $command->isInverted(),
41
            $spacing
42
        );
43
44
        return $canvas->toImage();
45
    }
46
}
47