Entry   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
c 1
b 0
f 0
dl 0
loc 48
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A allPossibilitiesFor() 0 7 1
A row() 0 3 1
A column() 0 3 1
A __toString() 0 7 1
A number() 0 3 1
A __construct() 0 5 1
1
<?php declare(strict_types=1);
2
3
namespace Stratadox\PuzzleSolver\Puzzle\Sudoku;
4
5
use Stratadox\PuzzleSolver\Move;
6
use Stratadox\PuzzleSolver\Moves;
7
use function array_map;
8
use function sprintf;
9
10
final class Entry implements Move
11
{
12
    /** @var int */
13
    private $number;
14
    /** @var int */
15
    private $row;
16
    /** @var int */
17
    private $column;
18
19
    public function __construct(int $number, int $row, int $column)
20
    {
21
        $this->number = $number;
22
        $this->row = $row;
23
        $this->column = $column;
24
    }
25
26
    public static function allPossibilitiesFor(int $row, int $column): Moves
27
    {
28
        return new Moves(...array_map(
29
            static function (int $number) use ($row, $column): Entry {
30
                return new self($number, $row, $column);
31
            },
32
            range(1, 9)
33
        ));
34
    }
35
36
    public function number(): int
37
    {
38
        return $this->number;
39
    }
40
41
    public function column(): int
42
    {
43
        return $this->column;
44
    }
45
46
    public function row(): int
47
    {
48
        return $this->row;
49
    }
50
51
    public function __toString(): string
52
    {
53
        return sprintf(
54
            '%d at (%d, %d)',
55
            $this->number,
56
            $this->column,
57
            $this->row
58
        );
59
    }
60
}
61