Failed Conditions
Push — ng ( 7180d6...8c4fca )
by Florent
04:12
created

ClientConfigurationRouteRule::__construct()   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 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2018 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace OAuth2Framework\Bundle\Rule;
15
16
use Base64Url\Base64Url;
17
use OAuth2Framework\Component\ClientRule\ClientRegistrationManagementRule as Base;
18
use OAuth2Framework\Component\Core\Client\ClientId;
19
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
20
use Symfony\Component\Routing\RouterInterface;
21
22
class ClientConfigurationRouteRule extends Base
23
{
24
    /**
25
     * @var RouterInterface
26
     */
27
    private $router;
28
29
    /**
30
     * ClientRegistrationManagementRule constructor.
31
     *
32
     * @param RouterInterface $router
33
     */
34
    public function __construct(RouterInterface $router)
35
    {
36
        $this->router = $router;
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    protected function getRegistrationClientUri(ClientId $clientId): string
43
    {
44
        return $this->router->generate('oauth2_server_client_configuration', ['client_id' => $clientId->getValue()], UrlGeneratorInterface::ABSOLUTE_URL);
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    protected function generateRegistrationAccessToken(): string
51
    {
52
        $length = random_int(50, 100);
53
54
        return Base64Url::encode(random_bytes($length));
55
    }
56
}
57