Test Failed
Push — master ( 085c8a...c2447a )
by Alexey
01:55
created

Configuration::getConfigTreeBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 52

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 1.216

Importance

Changes 0
Metric Value
dl 0
loc 52
ccs 16
cts 40
cp 0.4
rs 9.0472
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1.216

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 WoW-Apps/Symfony-Slack-Bot bundle for Symfony.
5
 * https://github.com/wow-apps/symfony-slack-bot
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 * https://github.com/wow-apps/symfony-slack-bot/blob/master/LICENSE
10
 *
11
 * For technical documentation.
12
 * https://wow-apps.github.io/symfony-slack-bot/docs/
13
 *
14
 * Author Alexey Samara <[email protected]>
15
 *
16
 * Copyright 2016 WoW-Apps.
17
 */
18
19
namespace WowApps\SlackBundle\DependencyInjection;
20
21
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
22
use Symfony\Component\Config\Definition\ConfigurationInterface;
23
24
/**
25
 * @author Alexey Samara <[email protected]>
26 1
 */
27
class Configuration implements ConfigurationInterface
28 1
{
29 1
    /**
30
     * {@inheritdoc}
31 1
     */
32 1
    public function getConfigTreeBuilder()
33 1
    {
34 1
        $treeBuilder = new TreeBuilder();
35 1
        $rootNode = $treeBuilder->root('wow_apps_slack');
0 ignored issues
show
Deprecated Code introduced by
The method Symfony\Component\Config...der\TreeBuilder::root() has been deprecated with message: since Symfony 4.3, pass the root name to the constructor instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
36 1
        $rootNode
37 1
            ->children()
38 1
                ->scalarNode('api_url')
39 1
                    ->isRequired()
40 1
                    ->cannotBeEmpty()
41 1
                ->end()
42 1
                ->arrayNode('channels')
43 1
                    ->scalarPrototype()->end()
44 1
                ->end()
45 1
                ->scalarNode('default_icon_url')
46 1
                    ->defaultValue('https://wow-apps.github.io/symfony-slack-bot/public/message-icon.png')
47
                ->end()
48 1
                ->scalarNode('default_username')
49
                    ->defaultValue('wow-apps/symfony-slack-bot')
50
                    ->cannotBeEmpty()
51
                ->end()
52
                ->scalarNode('default_fallback')->defaultValue('Can\'t display attachment in plain-text mode')->end()
53
                ->arrayNode('colors')
54
                    ->addDefaultsIfNotSet()
55
                    ->children()
56
                        ->scalarNode('default')->defaultValue('#607D8B')->end()
57
                        ->scalarNode('info')->defaultValue('#2196F3')->end()
58
                        ->scalarNode('warning')->defaultValue('#FF5722')->end()
59
                        ->scalarNode('success')->defaultValue('#8BC34A')->end()
60
                        ->scalarNode('danger')->defaultValue('#F44336')->end()
61
                    ->end()
62
                ->end()
63
                ->arrayNode('templates')
64
                    ->addDefaultsIfNotSet()
65
                    ->children()
66
                        ->arrayNode('exception')
67
                            ->addDefaultsIfNotSet()
68
                            ->children()
69
                                ->scalarNode('username')->defaultValue('Exception')->end()
70
                                ->scalarNode('channel')->defaultValue('general')->end()
71
                                ->scalarNode('icon')
72
                                    ->defaultValue(
73
                                        'https://wow-apps.github.io/symfony-slack-bot/public/exception-icon.png'
74
                                    )
75
                                ->end()
76
                            ->end()
77
                        ->end()
78
                    ->end()
79
                ->end()
80
            ->end();
81
82
        return $treeBuilder;
83
    }
84
}
85