GeneratorFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 19
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getGeneratorForType() 0 10 2
1
<?php
2
3
namespace PhpHocon\Generator;
4
5
use PhpHocon\Exception\UndefinedGeneratorException;
6
7
class GeneratorFactory
8
{
9
    const ARRAY_TYPE = 'Array';
10
11
    /**
12
     * @param string $type
13
     * @return Generator
14
     */
15
    public function getGeneratorForType($type)
16
    {
17
        $className = sprintf('PhpHocon\\Generator\\%sGenerator', $type);
18
19
        if (!class_exists($className)) {
20
            throw new UndefinedGeneratorException("The generator $className was not found");
21
        }
22
23
        return new $className;
24
    }
25
}
26