Failed Conditions
Push — ng ( 870bee...532144 )
by Florent
04:07
created

AccessTokenIdGenerator::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 5
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\Tests\TestBundle\Entity;
15
16
use Base64Url\Base64Url;
17
use OAuth2Framework\Component\Core\AccessToken\AccessTokenId;
18
use OAuth2Framework\Component\Core\AccessToken\AccessTokenIdGenerator as AccessTokenIdGeneratorInterface;
19
use OAuth2Framework\Component\Core\Client\ClientId;
20
use OAuth2Framework\Component\Core\DataBag\DataBag;
21
use OAuth2Framework\Component\Core\ResourceOwner\ResourceOwnerId;
22
use OAuth2Framework\Component\Core\ResourceServer\ResourceServerId;
23
24
class AccessTokenIdGenerator implements AccessTokenIdGeneratorInterface
25
{
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function create(ResourceOwnerId $resourceOwnerId, ClientId $clientId, DataBag $parameters, DataBag $metadatas, ? ResourceServerId $resourceServerId): AccessTokenId
30
    {
31
        $length = random_int(50, 100);
32
33
        return AccessTokenId::create(Base64Url::encode(random_bytes($length)));
34
    }
35
}
36