GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Config::getConfigTreeBuilder()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 57
Code Lines 54

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 54
nc 1
nop 0
dl 0
loc 57
rs 9.6818
c 2
b 0
f 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
3
declare(strict_types=1);
4
5
namespace Teebot\Configuration;
6
7
use Symfony\Component\Config\Definition\{
8
    Builder\TreeBuilder,
9
    ConfigurationInterface
10
};
11
12
class Config implements ConfigurationInterface
13
{
14
    public const DEFAULT_LIMIT = 1;
15
16
    public const DEFAULT_OFFSET = -1;
17
18
    private const DEFAULT_NAME = 'Teebot_test';
19
20
    private const DEFAULT_URL = 'https://api.telegram.org';
21
22
    private const DEFAULT_FILE_URL = 'https://api.telegram.org/file/bot';
23
24
    private const DEFAULT_TIMEOUT = 3;
25
26
    private const DEFAULT_METHOD = 'GET';
27
28
    private const BOT_PREFIX = 'bot';
29
30
    /**
31
     * Returns configuration tree builder object
32
     *
33
     * @return TreeBuilder
34
     */
35
    public function getConfigTreeBuilder(): TreeBuilder
36
    {
37
        $treeBuilder = new TreeBuilder();
38
        $rootNode = $treeBuilder->root('teebot');
39
        $rootNode
40
            ->addDefaultsIfNotSet()
0 ignored issues
show
Bug introduced by
The method addDefaultsIfNotSet() does not exist on Symfony\Component\Config...\Builder\NodeDefinition. It seems like you code against a sub-type of Symfony\Component\Config...\Builder\NodeDefinition such as Symfony\Component\Config...der\ArrayNodeDefinition. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
            ->/** @scrutinizer ignore-call */ 
41
              addDefaultsIfNotSet()
Loading history...
41
            ->children()
42
                ->scalarNode('token')
43
                    ->isRequired()
44
                    ->cannotBeEmpty()
45
                ->end()
46
                ->scalarNode('name')
47
                    ->defaultValue(self::DEFAULT_NAME)
48
                ->end()
49
                ->scalarNode('url')
50
                    ->defaultValue(self::DEFAULT_URL)
51
                ->end()
52
                ->scalarNode('file_url')
53
                    ->defaultValue(self::DEFAULT_FILE_URL)
54
                ->end()
55
                ->scalarNode('method')
56
                    ->defaultValue(self::DEFAULT_METHOD)
57
                ->end()
58
                ->scalarNode('bot_prefix')
59
                    ->defaultValue(self::BOT_PREFIX)
60
                ->end()
61
                ->scalarNode('timeout')
62
                    ->defaultValue(self::DEFAULT_TIMEOUT)
63
                ->end()
64
                ->arrayNode('options')
65
                    ->useAttributeAsKey('key')
66
                    ->prototype('scalar')->end()
67
                ->end()
68
                ->arrayNode('events')
69
                    ->prototype('array')
70
                        ->children()
71
                            ->scalarNode('command')->end()
72
                            ->scalarNode('type')->end()
73
                            ->scalarNode('class')->end()
74
                            ->arrayNode('params')
75
                                ->prototype('array')
76
                                    ->useAttributeAsKey('key')
77
                                    ->prototype('scalar')->end()
78
                                ->end()
79
                            ->end()
80
                        ->end()
81
                    ->end()
82
                ->end()
83
                ->arrayNode('logger')
84
                    ->children()
85
                        ->scalarNode('filename')
86
                        ->end()
87
                    ->end()
88
                ->end()
89
            ->end();
90
91
        return $treeBuilder;
92
    }
93
}
94