WordFinder   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 11
c 2
b 1
f 0
dl 0
loc 28
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A create() 0 12 1
A getRandomChar() 0 4 1
1
<?php
2
3
namespace CustomD\WordFinder;
4
5
use Illuminate\Support\Collection;
6
use Illuminate\Support\Facades\Config;
7
8
class WordFinder
9
{
10
11
    protected array $config;
12
13
    public function __construct($config)
14
    {
15
        $this->config = $config;
16
    }
17
18
    public function create(
19
        Collection $wordList,
20
        ?int $gridSize = null,
21
        ?int $min_word_length = null,
22
        ?int $max_word_length = null
23
    ): Grid {
24
        return (new Grid(
25
            $gridSize ?? $this->config['default_grid_size'],
26
            $min_word_length ?? $this->config['default_min_word_length'],
27
            $max_word_length ?? $this->config['default_max_word_length'],
28
            $wordList
29
        ))->generate();
30
    }
31
32
    public function getRandomChar(?CharacterMap $characterMap = null): string
33
    {
34
        $class = $characterMap ?? resolve($this->config['character_map']);
35
        return $class->/** @scrutinizer ignore-call */getRandomChar();
36
    }
37
}
38