Passed
Pull Request — master (#6100)
by Angel Fernando Quiroz
11:43
created

AbstractOAuth2ProviderController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 12
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getStartResponse() 0 10 2
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
declare(strict_types=1);
6
7
namespace Chamilo\CoreBundle\Controller\OAuth2;
8
9
use Chamilo\CoreBundle\ServiceHelper\AuthenticationConfigHelper;
10
use KnpU\OAuth2ClientBundle\Client\ClientRegistry;
11
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
12
use Symfony\Component\HttpFoundation\Response;
13
14
abstract class AbstractOAuth2ProviderController extends AbstractController
15
{
16
    protected function getStartResponse(
17
        string $providerName,
18
        ClientRegistry $clientRegistry,
19
        AuthenticationConfigHelper $authenticationConfigHelper,
20
    ): Response {
21
        if (!$authenticationConfigHelper->isOAuth2ProviderEnabled($providerName)) {
22
            throw $this->createAccessDeniedException();
23
        }
24
25
        return $clientRegistry->getClient($providerName)->redirect([], []);
26
    }
27
}
28