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

getStartResponse()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 3
dl 0
loc 10
rs 10
c 0
b 0
f 0
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