Completed
Push — master ( b7d603...d97993 )
by Paweł
07:44
created

Configuration::getConfigTreeBuilder()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 79
Code Lines 75

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 59
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 79
rs 8.8701
c 0
b 0
f 0
ccs 59
cts 59
cp 1
cc 1
eloc 75
nc 1
nop 0
crap 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/*
4
 * This file is part of the Superdesk Web Publisher Core Bundle.
5
 *
6
 * Copyright 2016 Sourcefabric z.u. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2016 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Bundle\CoreBundle\DependencyInjection;
16
17
use SWP\Bundle\CoreBundle\Factory\PackagePreviewTokenFactory;
18
use SWP\Bundle\CoreBundle\Model\ApiKeyInterface;
19
use SWP\Bundle\CoreBundle\Model\FacebookInstantArticlesArticle;
20
use SWP\Bundle\CoreBundle\Model\FacebookInstantArticlesArticleInterface;
21
use SWP\Bundle\CoreBundle\Model\FacebookInstantArticlesFeed;
22
use SWP\Bundle\CoreBundle\Model\FacebookInstantArticlesFeedInterface;
23
use SWP\Bundle\CoreBundle\Model\PackagePreviewToken;
24
use SWP\Bundle\CoreBundle\Model\PackagePreviewTokenInterface;
25
use SWP\Bundle\CoreBundle\Model\PublishDestination;
26
use SWP\Bundle\CoreBundle\Model\PublishDestinationInterface;
27
use SWP\Bundle\CoreBundle\Repository\ApiKeyRepository;
28
use SWP\Bundle\CoreBundle\Factory\ApiKeyFactory;
29
use SWP\Bundle\CoreBundle\Model\ApiKey;
30
use SWP\Bundle\CoreBundle\Repository\FacebookInstantArticlesArticleRepository;
31
use SWP\Bundle\StorageBundle\Doctrine\ORM\EntityRepository;
32
use SWP\Component\Storage\Factory\Factory;
33
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
34
use Symfony\Component\Config\Definition\ConfigurationInterface;
35
36
/**
37
 * This is the class that validates and merges configuration from your app/config files.
38
 *
39
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
40
 */
41 2
class Configuration implements ConfigurationInterface
42
{
43 2
    /**
44 2
     * {@inheritdoc}
45 2
     */
46 2
    public function getConfigTreeBuilder()
47 2
    {
48 2
        $treeBuilder = new TreeBuilder();
49 2
        $treeBuilder->root('swp_core')
50 2
            ->children()
51 2
                ->arrayNode('device_listener')
52 2
                    ->canBeEnabled()
53 2
                    ->info('Enable device detection in templates loader')
54 2
                ->end()
55 2
                ->arrayNode('persistence')
56 2
                    ->addDefaultsIfNotSet()
57 2
                    ->children()
58 2
                        ->arrayNode('orm')
59 2
                            ->addDefaultsIfNotSet()
60 2
                            ->canBeEnabled()
61 2
                            ->children()
62 2
                                ->arrayNode('classes')
63 2
                                ->addDefaultsIfNotSet()
64 2
                                ->children()
65 2
                                    ->arrayNode('api_key')
66 2
                                        ->addDefaultsIfNotSet()
67 2
                                        ->children()
68 2
                                            ->scalarNode('model')->cannotBeEmpty()->defaultValue(ApiKey::class)->end()
69 2
                                            ->scalarNode('repository')->defaultValue(ApiKeyRepository::class)->end()
70 2
                                            ->scalarNode('factory')->defaultValue(ApiKeyFactory::class)->end()
71 2
                                            ->scalarNode('interface')->defaultValue(ApiKeyInterface::class)->end()
72 2
                                            ->scalarNode('object_manager_name')->defaultValue(null)->end()
73 2
                                        ->end()
74 2
                                    ->end()
75 2
                                    ->arrayNode('facebook_instant_articles_feed')
76 2
                                        ->addDefaultsIfNotSet()
77 2
                                        ->children()
78 2
                                            ->scalarNode('model')->cannotBeEmpty()->defaultValue(FacebookInstantArticlesFeed::class)->end()
79 2
                                            ->scalarNode('interface')->defaultValue(FacebookInstantArticlesFeedInterface::class)->end()
80 2
                                            ->scalarNode('repository')->defaultValue(EntityRepository::class)->end()
81 2
                                            ->scalarNode('factory')->defaultValue(Factory::class)->end()
82 2
                                            ->scalarNode('object_manager_name')->defaultValue(null)->end()
83 2
                                        ->end()
84 2
                                    ->end()
85 2
                                    ->arrayNode('facebook_instant_articles_article')
86 2
                                        ->addDefaultsIfNotSet()
87 2
                                        ->children()
88 2
                                            ->scalarNode('model')->cannotBeEmpty()->defaultValue(FacebookInstantArticlesArticle::class)->end()
89 2
                                            ->scalarNode('interface')->defaultValue(FacebookInstantArticlesArticleInterface::class)->end()
90 2
                                            ->scalarNode('repository')->defaultValue(FacebookInstantArticlesArticleRepository::class)->end()
91 2
                                            ->scalarNode('factory')->defaultValue(Factory::class)->end()
92 2
                                            ->scalarNode('object_manager_name')->defaultValue(null)->end()
93 2
                                        ->end()
94 2
                                    ->end()
95 2
                                    ->arrayNode('publish_destination')
96 2
                                        ->addDefaultsIfNotSet()
97 2
                                        ->children()
98 2
                                            ->scalarNode('model')->cannotBeEmpty()->defaultValue(PublishDestination::class)->end()
99 2
                                            ->scalarNode('interface')->defaultValue(PublishDestinationInterface::class)->end()
100 2
                                            ->scalarNode('repository')->defaultValue(EntityRepository::class)->end()
101 2
                                            ->scalarNode('factory')->defaultValue(Factory::class)->end()
102 2
                                            ->scalarNode('object_manager_name')->defaultValue(null)->end()
103 2
                                        ->end()
104
                                    ->end()
105
                                    ->arrayNode('package_preview_token')
106 2
                                        ->addDefaultsIfNotSet()
107
                                        ->children()
108
                                            ->scalarNode('model')->cannotBeEmpty()->defaultValue(PackagePreviewToken::class)->end()
109
                                            ->scalarNode('interface')->defaultValue(PackagePreviewTokenInterface::class)->end()
110
                                            ->scalarNode('repository')->defaultValue(EntityRepository::class)->end()
111
                                            ->scalarNode('factory')->defaultValue(PackagePreviewTokenFactory::class)->end()
112
                                            ->scalarNode('object_manager_name')->defaultValue(null)->end()
113
                                        ->end()
114
                                    ->end()
115
                                ->end() // classes
116
                            ->end()
117
                        ->end()
118
                    ->end()
119
                ->end()
120
            ->end()
121
        ;
122
123
        return $treeBuilder;
124
    }
125
}
126