Passed
Push — master ( 36097f...93304f )
by Rafael
03:14
created

AbstractDefinitionExtension::buildConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 2
ccs 0
cts 1
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 0
nc 1
nop 1
crap 2
1
<?php
2
/*******************************************************************************
3
 *  This file is part of the GraphQL Bundle package.
4
 *
5
 *  (c) YnloUltratech <[email protected]>
6
 *
7
 *  For the full copyright and license information, please view the LICENSE
8
 *  file that was distributed with this source code.
9
 ******************************************************************************/
10
11
namespace Ynlo\GraphQLBundle\Definition\Extension;
12
13
use Doctrine\Common\Util\Inflector;
14
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
15
use Ynlo\GraphQLBundle\Definition\DefinitionInterface;
16
use Ynlo\GraphQLBundle\Definition\Registry\Endpoint;
17
18
/**
19
 * AbstractDefinitionExtension
20
 */
21
abstract class AbstractDefinitionExtension implements DefinitionExtensionInterface
22
{
23
    /**
24
     * {@inheritDoc}
25
     */
26
    public function getName(): string
27
    {
28
        $name = get_class($this);
29
        preg_match('/(\w+)$/', $name, $matches);
30
        $name = preg_replace('/Extension$/', null, $matches[1]);
31
        $name = preg_replace('/Definition$/', null, $name);
32
33
        return Inflector::tableize($name);
34
    }
35
36
    /**
37
     * {@inheritDoc}
38
     */
39
    public function buildConfig(ArrayNodeDefinition $root)
40
    {
41
42
    }
43
44
    /**
45
     * {@inheritDoc}
46
     */
47
    public function normalizeConfig(DefinitionInterface $definition, $config): array
48
    {
49
        if (is_bool($config)) {
50
            $config = ['enabled' => $config];
51
        }
52
53
        return $config;
54
    }
55
56
    /**
57
     * {@inheritDoc}
58
     */
59
    public function configure(DefinitionInterface $definition, Endpoint $endpoint, array $config)
60
    {
61
        // TODO: Implement configure() method.
62
    }
63
64
    /**
65
     * {@inheritDoc}
66
     */
67
    public function configureEndpoint(Endpoint $endpoint)
68
    {
69
        // TODO: Implement configureEndpoint() method.
70
    }
71
}
72