Passed
Push — master ( fd1239...ff3fed )
by Luiz Kim
02:25
created

iFoodConnectController::returnAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace ControleOnline\Controller\Oauth\iFood;
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 League\OAuth2\Client\Provider\GenericProvider;
0 ignored issues
show
Bug introduced by
The type League\OAuth2\Client\Provider\GenericProvider 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\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...
11
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...
12
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...
13
14
class iFoodConnectController 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_IFOOD_CLIENT_ID'];
22
        $this->clientSecret = $_ENV['OAUTH_IFOOD_CLIENT_SECRET'];
23
24
        $this->provider = new GenericProvider([
25
            'clientId'                => $this->clientId,
26
            'clientSecret'            => $this->clientSecret,
27
            'redirectUri'             => 'https://' . $this->domainService->getMainDomain() . '/oauth/ifood/return',
28
            'urlAuthorize'            => 'https://merchant-api.ifood.com.br/authentication/v1.0/oauth/authorize',
29
            'urlAccessToken'          => 'https://merchant-api.ifood.com.br/authentication/v1.0/oauth/token',
30
            'urlResourceOwnerDetails' => '', // iFood não usa isso
31
            'scopes' => 'merchant order catalog financial review logistics shipping item picking promotion events'
32
        ]);
33
    }
34
35
    #[Route('/oauth/ifood/connect', name: 'ifood_connect', methods: ['GET'])]
36
    public function connectAction()
37
    {
38
        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...
39
    }
40
41
    #[Route('/oauth/ifood/return', name: 'ifood_return', methods: ['GET', 'POST'])]
42
    public function returnAction(Request $request): JsonResponse
43
    {
44
        return parent::returnAction($request);
45
    }
46
}
47