GoogleConnectController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A connectAction() 0 4 1
A returnAction() 0 4 1
A __construct() 0 12 1
1
<?php
2
3
namespace ControleOnline\Controller\Oauth\Google;
4
5
use ControleOnline\Controller\Oauth\DefaultClientController;
6
use ControleOnline\Service\DomainService;
0 ignored issues
show
Bug introduced by
The type ControleOnline\Service\DomainService was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use ControleOnline\Service\UserService;
8
use Doctrine\ORM\EntityManagerInterface;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\EntityManagerInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Symfony\Component\HttpFoundation\Request;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpFoundation\Request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Symfony\Component\Routing\Attribute\Route;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Routing\Attribute\Route was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Symfony\Component\HttpFoundation\JsonResponse;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpFoundation\JsonResponse was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use League\OAuth2\Client\Provider\Google;
0 ignored issues
show
Bug introduced by
The type League\OAuth2\Client\Provider\Google was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
14
class GoogleConnectController extends DefaultClientController
15
{
16
    public function __construct(
17
        protected EntityManagerInterface $manager,
18
        protected UserService $userService,
19
        private DomainService $domainService
20
    ) {
21
        $this->clientId       = $_ENV['OAUTH_GOOGLE_CLIENT_ID'];
22
        $this->clientSecret   = $_ENV['OAUTH_GOOGLE_CLIENT_SECRET'];
23
24
        $this->provider = new Google([
25
            'clientId'     => $this->clientId,
26
            'clientSecret' => $this->clientSecret,
27
            'redirectUri'  => 'https://' . $this->domainService->getMainDomain() . '/oauth/google/return',
28
            //'hostedDomain' => 'example.com', // optional; used to restrict access to users on your G Suite/Google Apps for Business accounts
29
30
        ]);
31
    }
32
33
    #[Route('/oauth/google/connect', name: 'google_connect', methods: ['GET'])]
34
    public function connectAction()
35
    {
36
        return parent::connectAction();
0 ignored issues
show
Bug introduced by
Are you sure the usage of parent::connectAction() targeting ControleOnline\Controlle...roller::connectAction() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
37
    }
38
39
    #[Route('/oauth/google/return', name: 'google_return', methods: ['GET', 'POST'])]
40
    public function returnAction(Request $request): JsonResponse
41
    {
42
        return parent::returnAction($request);
43
    }
44
45
46
}
47