1 | <?php |
||||
2 | |||||
3 | declare(strict_types=1); |
||||
4 | |||||
5 | /** |
||||
6 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
||||
7 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
8 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
9 | * |
||||
10 | * Copyright (c) 2024 Mykhailo Shtanko [email protected] |
||||
11 | * |
||||
12 | * For the full copyright and license information, please view the LICENSE.MD |
||||
13 | * file that was distributed with this source code. |
||||
14 | */ |
||||
15 | |||||
16 | namespace FRZB\Component\MetricsPower\DependencyInjection; |
||||
17 | |||||
18 | use FRZB\Component\MetricsPower\Enum\StorageType; |
||||
19 | use Sentry\Options; |
||||
20 | use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
||||
21 | use Symfony\Component\Config\Definition\ConfigurationInterface; |
||||
22 | |||||
23 | class Configuration implements ConfigurationInterface |
||||
24 | { |
||||
25 | /** CONFIG */ |
||||
26 | public const METRICS_POWER = 'metrics_power'; |
||||
27 | public const METRICS_POWER_CONFIG = 'metrics_power.config'; |
||||
28 | |||||
29 | /** SENTRY */ |
||||
30 | public const SENTRY_CONFIG = 'sentry'; |
||||
31 | public const SENTRY_DSN = 'dsn'; |
||||
32 | public const SENTRY_ENVIRONMENT = 'environment'; |
||||
33 | |||||
34 | /** PROMETHEUS */ |
||||
35 | public const PROMETHEUS_CONFIG = 'prometheus'; |
||||
36 | public const PROMETHEUS_STORAGE = 'storage'; |
||||
37 | public const PROMETHEUS_REDIS = 'redis'; |
||||
38 | public const PROMETHEUS_HANDLE_ALL_MESSAGES = 'handle_all_messages'; |
||||
39 | |||||
40 | public function getConfigTreeBuilder(): TreeBuilder |
||||
41 | { |
||||
42 | $builder = new TreeBuilder(self::METRICS_POWER); |
||||
43 | $root = $builder->getRootNode(); |
||||
44 | |||||
45 | $root |
||||
46 | ->children() |
||||
47 | ->arrayNode(self::SENTRY_CONFIG) |
||||
48 | ->children() |
||||
49 | ->scalarNode(self::SENTRY_DSN)->isRequired()->cannotBeEmpty()->end() |
||||
50 | ->scalarNode(self::SENTRY_ENVIRONMENT)->isRequired()->defaultValue((new Options())->getEnvironment())->end() |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
51 | ->end() |
||||
52 | ->end() |
||||
53 | ->end() |
||||
54 | ; |
||||
55 | |||||
56 | $root |
||||
57 | ->children() |
||||
58 | ->arrayNode(self::PROMETHEUS_CONFIG) |
||||
59 | ->children() |
||||
60 | ->enumNode(self::PROMETHEUS_STORAGE)->isRequired()->cannotBeEmpty()->values(StorageType::values())->end() |
||||
61 | ->booleanNode(self::PROMETHEUS_HANDLE_ALL_MESSAGES)->defaultTrue()->end() |
||||
0 ignored issues
–
show
The method
booleanNode() does not exist on Symfony\Component\Config...der\NodeParentInterface . It seems like you code against a sub-type of Symfony\Component\Config...der\NodeParentInterface such as Symfony\Component\Config...ion\Builder\NodeBuilder .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
62 | ->arrayNode(self::PROMETHEUS_REDIS) |
||||
63 | ->children() |
||||
64 | ->scalarNode('host')->end() |
||||
65 | ->integerNode('port')->end() |
||||
66 | ->integerNode('database')->end() |
||||
67 | ->floatNode('timeout')->end() |
||||
68 | ->floatNode('read_timeout')->end() |
||||
69 | ->booleanNode('persistent_connections')->end() |
||||
70 | ->scalarNode('password')->end() |
||||
71 | ->end() |
||||
72 | ->end() |
||||
73 | ->end() |
||||
74 | ->end() |
||||
75 | ->end() |
||||
76 | ; |
||||
77 | |||||
78 | $root |
||||
79 | ->children() |
||||
80 | ->booleanNode('test')->defaultFalse()->end() |
||||
81 | ->end() |
||||
0 ignored issues
–
show
The method
end() does not exist on Symfony\Component\Config...der\NodeParentInterface . It seems like you code against a sub-type of said class. However, the method does not exist in Symfony\Component\Config...ion\Builder\TreeBuilder . Are you sure you never get one of those?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
82 | ; |
||||
83 | |||||
84 | return $builder; |
||||
85 | } |
||||
86 | } |
||||
87 |