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

InitialAccessTokenIdType::requiresSQLCommentHint()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
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\ClientRegistrationEndpoint\InitialAccessTokenId;
20
21
final class InitialAccessTokenIdType extends Type
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function convertToDatabaseValue($value, AbstractPlatform $platform): string
27
    {
28
        Assertion::isInstanceOf($value, InitialAccessTokenId::class, 'Invalid object');
29
30
        return $value->getValue();
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function convertToPHPValue($value, AbstractPlatform $platform): InitialAccessTokenId
37
    {
38
        return new InitialAccessTokenId($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 'initial_access_token_id';
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function requiresSQLCommentHint(AbstractPlatform $platform): bool
61
    {
62
        return true;
63
    }
64
}
65