Align::resetAlign()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 2
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 5
ccs 0
cts 4
cp 0
crap 12
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\Language\Fingerprint\Concerns;
16
17
use PhpAidc\LabelPrinter\Enum\Anchor;
18
use PhpAidc\LabelPrinter\Contract\Command;
19
use PhpAidc\LabelPrinter\Language\Fingerprint;
20
use PhpAidc\LabelPrinter\Command\Concerns\Alignable;
21
22
trait Align
23
{
24
    public function align(Command $command)
25
    {
26
        /** @var Command|Alignable $command */
27
        if ($command->getAnchor() && !$command->getAnchor()->equals(Anchor::SOUTHWEST())) {
0 ignored issues
show
Bug introduced by
The method getAnchor() does not exist on PhpAidc\LabelPrinter\Contract\Command. It seems like you code against a sub-type of PhpAidc\LabelPrinter\Contract\Command such as PhpAidc\LabelPrinter\Command\Barcode or PhpAidc\LabelPrinter\Command\TextLine or PhpAidc\LabelPrinter\Command\TextBlock. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

27
        if ($command->/** @scrutinizer ignore-call */ getAnchor() && !$command->getAnchor()->equals(Anchor::SOUTHWEST())) {
Loading history...
28
            $anchor = $command->getAnchor()->getValue();
29
30
            $newAnchor = $anchor + 6;
31
32
            if ($newAnchor > 9) {
33
                $newAnchor = $anchor > 6 ? $anchor - 6 : $anchor;
34
            }
35
36
            yield "AN {$newAnchor}";
37
        }
38
    }
39
40
    public function resetAlign(Command $command)
41
    {
42
        /** @var Command|Alignable $command */
43
        if ($command->getAnchor() && !$command->getAnchor()->equals(Anchor::SOUTHWEST())) {
44
            yield 'AN '.Fingerprint::DEFAULT_ANCHOR;
45
        }
46
    }
47
}
48