WordFinder::getRandomChar()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 2
c 1
b 1
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
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