Failed Conditions
Push — master ( f5f64c...3a5b4f )
by Florent
03:17
created

RefreshTokenIdType   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 42
rs 10
c 2
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A getSQLDeclaration() 0 3 1
A convertToPHPValue() 0 3 1
A requiresSQLCommentHint() 0 3 1
A convertToDatabaseValue() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2019 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\ServerBundle\Doctrine\Type;
15
16
use Assert\Assertion;
17
use Doctrine\DBAL\Platforms\AbstractPlatform;
18
use Doctrine\DBAL\Types\Type;
19
use OAuth2Framework\Component\RefreshTokenGrant\RefreshTokenId;
20
21
final class RefreshTokenIdType extends Type
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function convertToDatabaseValue($value, AbstractPlatform $platform): string
27
    {
28
        Assertion::isInstanceOf($value, RefreshTokenId::class, 'Invalid object');
29
30
        return $value->getValue();
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function convertToPHPValue($value, AbstractPlatform $platform): RefreshTokenId
37
    {
38
        return new RefreshTokenId($value);
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string
45
    {
46
        return $platform->getClobTypeDeclarationSQL($fieldDeclaration);
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function getName(): string
53
    {
54
        return 'refresh_token_id';
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function requiresSQLCommentHint(AbstractPlatform $platform): bool
61
    {
62
        return true;
63
    }
64
}
65