Passed
Pull Request — master (#9)
by Daniel
02:50
created

EntryPoint::start()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 9
rs 10
1
<?php
2
3
namespace CodeCloud\Bundle\ShopifyBundle\Security;
4
5
use Symfony\Component\HttpFoundation\RedirectResponse;
6
use Symfony\Component\HttpFoundation\Request;
7
use Symfony\Component\HttpFoundation\Response;
8
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
9
use Symfony\Component\Security\Core\Exception\AuthenticationException;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Securi...AuthenticationException 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\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Securi...tionEntryPointInterface 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
12
/**
13
 * Restarts the Shopify OAuth flow, or prompts user to access the app via Shopify admin.
14
 */
15
class EntryPoint implements AuthenticationEntryPointInterface
16
{
17
    /**
18
     * @var UrlGeneratorInterface
19
     */
20
    private $urlGenerator;
21
22
    public function __construct(UrlGeneratorInterface $urlGenerator)
23
    {
24
        $this->urlGenerator = $urlGenerator;
25
    }
26
27
    public function start(Request $request, AuthenticationException $authException = null)
28
    {
29
        if (!$request->get('shop')) {
30
            return new Response('Your session has expired. Please access the app via Shopify Admin again.');
31
        }
32
33
        return new RedirectResponse(
34
            $this->urlGenerator->generate('codecloud_shopify_auth', [
35
                'shop' => $request->get('shop'),
36
            ])
37
        );
38
    }
39
}
40