Dictionary::dictionary()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Knp\DictionaryBundle\Faker\Provider;
6
7
use Faker\Generator;
8
use Faker\Provider\Base;
9
use Knp\DictionaryBundle\Dictionary\Collection;
10
11
final class Dictionary extends Base
12
{
13
    public function __construct(private Collection $collection, ?Generator $generator = null)
14
    {
15
        if (!$generator instanceof Generator) {
16
            $generator = new Generator();
17
            $generator->addProvider($this);
18 3
        }
19
20 3
        parent::__construct($generator);
21
    }
22 3
23 3
    /**
24 3
     * @return mixed
25
     */
26
    public function dictionary(string $name)
27 3
    {
28 3
        return self::randomElement($this->collection[$name]->getKeys());
29
    }
30
}
31