Rotate::resetRotate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 5
ccs 0
cts 4
cp 0
crap 6
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\Angle;
18
use PhpAidc\LabelPrinter\Contract\Command;
19
use PhpAidc\LabelPrinter\Language\Fingerprint;
20
use PhpAidc\LabelPrinter\Command\Concerns\Rotatable;
21
22
trait Rotate
23
{
24
    public function rotate(Command $command)
25
    {
26
        /** @var Command|Rotatable $command */
27
        if (!$command->getRotation()->equals(Angle::_0())) {
0 ignored issues
show
Bug introduced by
The method getRotation() does not exist on PhpAidc\LabelPrinter\Contract\Command. It seems like you code against a sub-type of said class. However, the method does not exist in PhpAidc\LabelPrinter\Command\Clear or PhpAidc\LabelPrinter\Command\Raw or PhpAidc\LabelPrinter\Command\Bitmap. Are you sure you never get one of those? ( 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 */ getRotation()->equals(Angle::_0())) {
Loading history...
28
            yield \sprintf('DIR %d', $command->getRotation()->getValue() + 1);
29
        }
30
    }
31
32
    public function resetRotate(Command $command)
33
    {
34
        /** @var Command|Rotatable $command */
35
        if (!$command->getRotation()->equals(Angle::_0())) {
36
            yield 'DIR '.Fingerprint::DEFAULT_DIRECTION;
37
        }
38
    }
39
}
40