ConstantGeneratorFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 12
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getGenerator() 0 7 2
1
<?php
2
3
namespace WebnetFr\DatabaseAnonymizer\GeneratorFactory;
4
5
use WebnetFr\DatabaseAnonymizer\Exception\UnsupportedGeneratorException;
6
use WebnetFr\DatabaseAnonymizer\Generator\Constant;
7
use WebnetFr\DatabaseAnonymizer\Generator\GeneratorInterface;
8
9
/**
10
 * Creates the instance of @see Constant generator.
11
 *
12
 * @author Vlad Riabchenko <[email protected]>
13
 */
14
class ConstantGeneratorFactory implements GeneratorFactoryInterface
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19
    public function getGenerator(array $config): GeneratorInterface
20
    {
21
        if ('constant' !== $config['generator']) {
22
            throw new UnsupportedGeneratorException($config['generator'].' generator is not known');
23
        }
24
25
        return new Constant($config['value']);
26
    }
27
}
28