DebugCalcService   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 66
ccs 29
cts 29
cp 1
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A reverseTiles() 0 5 1
A calculate() 0 7 1
A __construct() 0 8 1
A isTargetTile() 0 7 1
A findStartIndex() 0 7 1
A prepare() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PanicLabCore\Services\Debug;
6
7
use PanicLabCore\Services\CalcService;
8
use PanicLabCore\Services\Debug\Log\DebugLoggerInterface;
9
use PanicLabCore\Services\Handlers\TileHandlerCollectorInterface;
10
use PanicLabCore\Structs;
11
12
class DebugCalcService extends CalcService
13
{
14
    /** @var DebugLoggerInterface */
15
    private $debugLogger;
16
17 10
    public function __construct(
18
        DebugLoggerInterface $debugLogger,
19
        TileHandlerCollectorInterface $tileHandlerCollector,
20
        int $maxSteps
21
    ) {
22 10
        $this->debugLogger = $debugLogger;
23
24 10
        parent::__construct($tileHandlerCollector, $maxSteps);
25 10
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30 2
    public function calculate(array $tiles, Structs\Dice $diceResult): Structs\GermTile
31
    {
32 2
        $this->debugLogger->logBefore('calculate', ['tiles' => $tiles, 'dice' => $diceResult]);
33 2
        $foundTile = parent::calculate($tiles, $diceResult);
34 2
        $this->debugLogger->logAfter('calculate', ['foundTile' => $foundTile]);
35
36 2
        return $foundTile;
37
    }
38
39 4
    public function prepare(Structs\Dice $diceResult): void
40
    {
41 4
        $this->debugLogger->logBefore('prepare', ['tiles' => $this->tiles, 'dice' => $diceResult]);
42 4
        parent::prepare($diceResult);
43 4
        $this->debugLogger->logAfter('prepare', ['tiles' => $this->tiles]);
44 4
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 2
    public function reverseTiles(): void
50
    {
51 2
        $this->debugLogger->logBefore('reverseTiles', ['tiles' => $this->tiles]);
52 2
        parent::reverseTiles();
53 2
        $this->debugLogger->logAfter('reverseTiles', ['tiles' => $this->tiles]);
54 2
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59 6
    public function findStartIndex(string $entryColor): int
60
    {
61 6
        $this->debugLogger->logBefore('findStartIndex', ['entryColor' => $entryColor]);
62 6
        $startIndex = parent::findStartIndex($entryColor);
63 6
        $this->debugLogger->logAfter('findStartIndex', ['startIndex' => $startIndex]);
64
65 6
        return $startIndex;
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     */
71 4
    public function isTargetTile(Structs\Tile $tile): bool
72
    {
73 4
        $this->debugLogger->logBefore('isTargetTile', ['searchedTile' => $tile, 'targetTile' => $this->target]);
74 4
        $isTargetTile = parent::isTargetTile($tile);
75 4
        $this->debugLogger->logAfter('isTargetTile', ['isTargetTile' => $isTargetTile]);
76
77 4
        return $isTargetTile;
78
    }
79
}
80