RotateAction   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 35
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 7 1
A getAlias() 0 4 1
A getArguments() 0 4 1
1
<?php
2
declare(strict_types=1);
3
namespace Thunder\Logeek\Action;
4
5
use Thunder\Logeek\ActionInterface;
6
use Thunder\Logeek\Board;
7
8
final class RotateAction implements ActionInterface
9
{
10
    private static $rotateMap = [
11
        'left' => [
12
            'up' => 'left',
13
            'down' => 'right',
14
            'right' => 'up',
15
            'left' => 'down',
16
        ],
17
        'right' => [
18
            'up' => 'right',
19
            'down' => 'left',
20
            'right' => 'down',
21
            'left' => 'up',
22
        ],
23
    ];
24
25
    public function execute(Board $board, string $alias, array $operation)
26
    {
27
        $direction = $board->getActorDirection($alias);
28
        $newDirection = static::$rotateMap[$operation['direction']][$direction];
0 ignored issues
show
Comprehensibility introduced by
Since Thunder\Logeek\Action\RotateAction is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
29
        $board->debug('Rotate[%s] From[%s] To[%s]', $operation['direction'], $direction, $newDirection);
30
        $board->setActorDirection($alias, $newDirection);
31
    }
32
33
    public function getAlias(): string
34
    {
35
        return 'rotate';
36
    }
37
38
    public function getArguments(): array
39
    {
40
        return ['direction'];
41
    }
42
}
43