GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( cc1a00...2cee89 )
by Christian
15:25
created

StartAuthAction::generateUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 3
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * (c) Christian Gripp <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Core23\FacebookBundle\Action;
13
14
use Core23\FacebookBundle\Connection\FacebookConnection;
15
use Symfony\Component\HttpFoundation\RedirectResponse;
16
use Symfony\Component\HttpFoundation\Response;
17
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
18
use Symfony\Component\Routing\RouterInterface;
19
20
final class StartAuthAction
21
{
22
    /**
23
     * @var RouterInterface
24
     */
25
    private $router;
26
27
    /**
28
     * @var FacebookConnection
29
     */
30
    private $facebookConnection;
31
32
    /**
33
     * @var string[]
34
     */
35
    private $permissions;
36
37
    /**
38
     * StartAuthAction constructor.
39
     *
40
     * @param RouterInterface    $router
41
     * @param FacebookConnection $facebookConnection
42
     * @param string[]           $permissions
43
     */
44
    public function __construct(RouterInterface $router, FacebookConnection $facebookConnection, array $permissions)
45
    {
46
        $this->router             = $router;
47
        $this->facebookConnection = $facebookConnection;
48
        $this->permissions        = $permissions;
49
    }
50
51
    /**
52
     * @return Response
53
     */
54
    public function __invoke(): Response
55
    {
56
        $fb     = $this->facebookConnection;
57
        $helper = $fb->getRedirectLoginHelper();
58
59
        return new RedirectResponse($helper->getLoginUrl(
60
            $this->generateUrl('core23_facebook_check', [], UrlGeneratorInterface::ABSOLUTE_URL),
61
            $this->permissions
62
        ));
63
    }
64
65
    /**
66
     * Generates a URL from the given parameters.
67
     *
68
     * @param string $route         The name of the route
69
     * @param array  $parameters    An array of parameters
70
     * @param int    $referenceType The type of reference (one of the constants in UrlGeneratorInterface)
71
     *
72
     * @return string The generated URL
73
     */
74
    private function generateUrl($route, array $parameters = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH): string
75
    {
76
        return $this->router->generate($route, $parameters, $referenceType);
77
    }
78
}
79