Completed
Pull Request — master (#2)
by
unknown
05:39
created

getConfigTreeBuilder()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 55

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 55
rs 8.9818
c 0
b 0
f 0
cc 1
nc 1
nop 0

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
namespace OmnideskBundle\Configuration\Cases;
3
4
use OmnideskBundle\Model\Cases;
5
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6
use Symfony\Component\Config\Definition\ConfigurationInterface;
7
8
/**
9
 * Class AddCasesRequestConfiguration
10
 * @package OmnideskBundle\Configuration\Cases
11
 */
12
class AddCasesRequestConfiguration implements ConfigurationInterface
13
{
14
    /**
15
     * @return TreeBuilder
16
     */
17
    public function getConfigTreeBuilder()
18
    {
19
        $treeBuilder = new TreeBuilder();
20
21
        $rootNode = $treeBuilder->root('params');
22
23
        $rootNode
24
            ->children()
25
                ->scalarNode('user_email')
26
                    ->defaultNull()
27
                ->end()
28
                ->scalarNode('user_phone')
29
                    ->defaultNull()
30
                ->end()
31
                ->scalarNode('user_full_name')
32
                    ->defaultNull()
33
                ->end()
34
                ->scalarNode('subject')
35
                    ->isRequired()
36
                    ->cannotBeEmpty()
37
                ->end()
38
                ->scalarNode('content')
39
                    ->isRequired()
40
                    ->cannotBeEmpty()
41
                ->end()
42
                ->scalarNode('content_html')
43
                    ->isRequired()
44
                    ->cannotBeEmpty()
45
                ->end()
46
                ->scalarNode('group_id')
47
                    ->defaultNull()
48
                ->end()
49
                ->scalarNode('language_id')
50
                    ->defaultNull()
51
                ->end()
52
                ->arrayNode('custom_fields')
53
                    ->prototype('scalar')
54
                    ->end()
55
                ->end()
56
                ->arrayNode('labels')
57
                ->end()
58
                ->arrayNode('attachments')
59
                    ->prototype('scalar')
60
                    ->end()
61
                ->end()
62
                ->scalarNode('priority')
63
                    ->defaultNull(Cases::PRIORITY_LOW)
64
                ->end()
65
                ->scalarNode('staff_id')
66
                    ->defaultNull()
67
                ->end()
68
            ->end();
69
70
        return $treeBuilder;
71
    }
72
}
73