ResourceOwnerPasswordCredentialSource::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\Grant\ResourceOwnerPasswordCredential;
15
16
use OAuth2Framework\Component\ResourceOwnerPasswordCredentialsGrant\ResourceOwnerPasswordCredentialManager;
17
use OAuth2Framework\Component\ResourceOwnerPasswordCredentialsGrant\ResourceOwnerPasswordCredentialsGrantType;
18
use OAuth2Framework\ServerBundle\Component\Component;
19
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
20
use Symfony\Component\Config\FileLocator;
21
use Symfony\Component\DependencyInjection\ContainerBuilder;
22
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
23
24
class ResourceOwnerPasswordCredentialSource implements Component
25
{
26
    public function name(): string
27
    {
28
        return 'resource_owner_password_credential';
29
    }
30
31
    public function load(array $configs, ContainerBuilder $container): void
32
    {
33
        if (!class_exists(ResourceOwnerPasswordCredentialsGrantType::class) || !$configs['grant']['resource_owner_password_credential']['enabled']) {
34
            return;
35
        }
36
        $loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config/grant'));
37
        $loader->load('resource_owner_password_credential.php');
38
39
        $container->setAlias(ResourceOwnerPasswordCredentialManager::class, $configs['grant']['resource_owner_password_credential']['password_credential_manager']);
40
    }
41
42
    public function getNodeDefinition(ArrayNodeDefinition $node, ArrayNodeDefinition $rootNode): void
43
    {
44
        if (!class_exists(ResourceOwnerPasswordCredentialsGrantType::class)) {
45
            return;
46
        }
47
        $node->children()
48
            ->arrayNode('resource_owner_password_credential')
49
            ->canBeEnabled()
50
            ->children()
51
            ->scalarNode('password_credential_manager')
52
            ->info('The password credential manager.')
53
            ->isRequired()
54
            ->end()
55
            ->end()
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

55
            ->/** @scrutinizer ignore-call */ end()
Loading history...
56
            ->end()
57
            ->end()
58
        ;
59
    }
60
61
    public function build(ContainerBuilder $container): void
62
    {
63
    }
64
65
    public function prepend(ContainerBuilder $container, array $config): array
66
    {
67
        return [];
68
    }
69
}
70