Completed
Push — master ( 300eda...15c856 )
by Rafael
09:26
created

AbstractDefinitionPlugin::normalizeConfig()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 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\Plugin;
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
abstract class AbstractDefinitionPlugin implements DefinitionPluginInterface
19
{
20
    /**
21
     * {@inheritDoc}
22
     */
23
    public function getName(): string
24
    {
25
        $name = \get_class($this);
26
        preg_match('/(\w+)$/', $name, $matches);
27
        $name = preg_replace('/Plugin/', null, $matches[1]);
28
        $name = preg_replace('/Definition$/', null, $name);
29
30
        return Inflector::tableize($name);
31
    }
32
33
    /**
34
     * {@inheritDoc}
35
     */
36
    public function buildConfig(ArrayNodeDefinition $root): void
37
    {
38
    }
39
40
    /**
41
     * {@inheritDoc}
42
     */
43
    public function normalizeConfig(DefinitionInterface $definition, $config): array
44
    {
45
        if (\is_bool($config)) {
46
            $config = ['enabled' => $config];
47
        }
48
49
        return $config;
50
    }
51
52
    /**
53
     * {@inheritDoc}
54
     */
55
    public function configure(DefinitionInterface $definition, Endpoint $endpoint, array $config): void
56
    {
57
    }
58
59
    /**
60
     * {@inheritDoc}
61
     */
62
    public function configureEndpoint(Endpoint $endpoint): void
63
    {
64
    }
65
}
66