Failed Conditions
Push — ng ( 625bbc...a06888 )
by Florent
08:03
created

OAuth2FrameworkBundle   B

Complexity

Total Complexity 7

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 16

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 16
dl 0
loc 76
rs 8.4614
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A boot() 0 5 1
A getContainerExtension() 0 4 1
A build() 0 11 2
A getComponents() 0 23 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2018 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\Bundle;
15
16
use OAuth2Framework\Bundle\DependencyInjection\OAuth2FrameworkExtension;
17
use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
use Symfony\Component\HttpKernel\Bundle\Bundle;
20
21
class OAuth2FrameworkBundle extends Bundle
22
{
23
    /**
24
     * @var Component\Component[]
25
     */
26
    private $components = [];
27
28
    /**
29
     * JoseFrameworkBundle constructor.
30
     */
31
    public function __construct()
32
    {
33
        foreach ($this->getComponents() as $component) {
34
            $this->components[$component->name()] = $component;
35
        }
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function boot()
42
    {
43
        parent::boot();
44
        //$this->container->get('twig.loader')->addPath(__DIR__.'/Resources/views', 'OAuth2FrameworkBundle');
0 ignored issues
show
Unused Code Comprehensibility introduced by
74% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function getContainerExtension()
51
    {
52
        return new OAuth2FrameworkExtension('oauth2_server', $this->components);
0 ignored issues
show
Documentation introduced by
$this->components is of type array<integer,object<OAu...e\Component\Component>>, but the function expects a array<integer,object<OAu...n\Component\Component>>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58
    public function build(ContainerBuilder $container)
59
    {
60
        parent::build($container);
61
        foreach ($this->components as $component) {
62
            $component->build($container);
63
        }
64
65
        /* @var SecurityExtension $extension */
66
        //$extension = $container->getExtension('security');
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
67
        //$extension->addSecurityListenerFactory(new OAuth2SecurityFactory());
0 ignored issues
show
Unused Code Comprehensibility introduced by
73% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
68
    }
69
70
    /**
71
     * @return Component\Component[]
72
     */
73
    private function getComponents(): array
74
    {
75
        return [
76
            new Component\Core\OAuth2ResponseSource(),
77
            new Component\Core\ClientSource(),
78
            new Component\Core\AccessTokenSource(),
79
            new Component\Core\UserAccountSource(),
80
            new Component\Core\ServicesSource(),
81
            new Component\Core\ResourceServerRepositorySource(),
82
            new Component\ClientRule\ClientRuleSource(),
83
            new Component\ClientAuthentication\ClientAuthenticationSource(),
84
85
            new Component\Scope\ScopeSource(),
86
            new Component\TokenType\TokenTypeSource(),
87
            new Component\Endpoint\EndpointSource(),
88
            new Component\Grant\GrantSource(),
89
            new Component\OpenIdConnect\OpenIdConnectSource(),
90
91
            /*new Component\FirewallSource(),
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
92
            new Component\HttpSource(),
93
            new Component\KeySet(),*/
94
        ];
95
    }
96
}
97