ConstructorFactory::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Crossword\Features\Constructor;
6
7
use App\Crossword\Features\Constructor\Figured\FiguredConstructor;
8
use App\Crossword\Features\Constructor\Normal\AttemptWordFinder;
9
use App\Crossword\Features\Constructor\Normal\NormalConstructor;
10
use App\Crossword\Features\Constructor\Scanner\GridScanner;
11
use App\Crossword\Features\Constructor\Scanner\RowXScanner;
12
use App\Crossword\Features\Constructor\Scanner\RowYScanner;
13
use App\Crossword\Features\Constructor\Type\Type;
14
15
class ConstructorFactory
16
{
17
    private WordFinder $wordFinder;
18
19
    public function __construct(WordFinder $wordFinder)
20
    {
21
        $this->wordFinder = $wordFinder;
22
    }
23
24
    public function create(Type $type): ConstructorInterface
25
    {
26
        return match ((string) $type->getValue()) {
27
            Type::NORMAL => new NormalConstructor(
28
                new AttemptWordFinder($this->wordFinder),
29
                new GridScanner(new RowXScanner(), new RowYScanner())
30
            ),
31
            Type::FIGURED => new FiguredConstructor(),
32
        };
33
    }
34
}
35