CustomValuesSource::prepend()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2019 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace OAuth2Framework\ServerBundle\Component\Endpoint\Metadata;
15
16
use OAuth2Framework\ServerBundle\Component\Component;
17
use OAuth2Framework\ServerBundle\Component\Endpoint\Metadata\Compiler\CustomValuesCompilerPass;
18
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
19
use Symfony\Component\DependencyInjection\ContainerBuilder;
20
21
class CustomValuesSource implements Component
22
{
23
    public function name(): string
24
    {
25
        return 'custom_routes';
26
    }
27
28
    public function load(array $configs, ContainerBuilder $container): void
29
    {
30
        $container->setParameter('oauth2_server.endpoint.metadata.custom_values', $configs['endpoint']['metadata']['custom_values']);
31
    }
32
33
    public function getNodeDefinition(ArrayNodeDefinition $node, ArrayNodeDefinition $rootNode): void
34
    {
35
        $node->children()
36
            ->arrayNode('custom_values')
37
            ->info('Custom values added to the metadata response.')
38
            ->useAttributeAsKey('name')
39
            ->variablePrototype()->end()
40
            ->treatNullLike([])
0 ignored issues
show
Bug introduced by
The method treatNullLike() 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...\Builder\NodeDefinition. ( 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 */ treatNullLike([])
Loading history...
41
            ->treatFalseLike([])
42
            ->end()
43
            ->end()
44
        ;
45
    }
46
47
    public function build(ContainerBuilder $container): void
48
    {
49
        $container->addCompilerPass(new CustomValuesCompilerPass());
50
    }
51
52
    public function prepend(ContainerBuilder $container, array $config): array
53
    {
54
        return [];
55
    }
56
}
57