Failed Conditions
Push — master ( 349866...67c1d1 )
by Florent
10:56 queued 06:08
created

OAuth2EntryPoint   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 34
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A start() 0 13 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\SecurityBundle\Security\EntryPoint;
15
16
use OAuth2Framework\Component\Core\Message\OAuth2Message;
17
use OAuth2Framework\Component\Core\Message\OAuth2MessageFactoryManager;
18
use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory;
19
use Symfony\Component\HttpFoundation\Request;
20
use Symfony\Component\Security\Core\Exception\AuthenticationException;
21
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
22
23
final class OAuth2EntryPoint implements AuthenticationEntryPointInterface
24
{
25
    /**
26
     * @var OAuth2MessageFactoryManager
27
     */
28
    private $oauth2ResponseFactoryManager;
29
30
    /**
31
     * OAuth2EntryPoint constructor.
32
     *
33
     * @param OAuth2MessageFactoryManager $oauth2ResponseFactoryManager
34
     */
35
    public function __construct(OAuth2MessageFactoryManager $oauth2ResponseFactoryManager)
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $oauth2ResponseFactoryManager exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
36
    {
37
        $this->oauth2ResponseFactoryManager = $oauth2ResponseFactoryManager;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function start(Request $request, AuthenticationException $authException = null)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
44
    {
45
        $psr7Response = $this->oauth2ResponseFactoryManager->getResponse(
46
            new OAuth2Message(
47
                401,
48
                OAuth2Message::ERROR_ACCESS_DENIED,
49
                'OAuth2 authentication required'
50
            )
51
        );
52
        $factory = new HttpFoundationFactory();
53
54
        return $factory->createResponse($psr7Response);
55
    }
56
}
57