BigIntType.php 830 Bytes
Newer Older
1
<?php
2

Michael Moravec's avatar
Michael Moravec committed
3 4
declare(strict_types=1);

5
namespace Doctrine\DBAL\Types;
6

7
use Doctrine\DBAL\ParameterType;
8 9
use Doctrine\DBAL\Platforms\AbstractPlatform;

10 11 12
/**
 * Type that maps a database BIGINT to a PHP string.
 */
13
class BigIntType extends Type implements PhpIntegerMappingType
14
{
Sergei Morozov's avatar
Sergei Morozov committed
15
    public function getName(): string
16
    {
17
        return Types::BIGINT;
18 19
    }

Benjamin Morel's avatar
Benjamin Morel committed
20 21 22
    /**
     * {@inheritdoc}
     */
Sergei Morozov's avatar
Sergei Morozov committed
23
    public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
24
    {
25
        return $platform->getBigIntTypeDeclarationSQL($column);
26
    }
27

Sergei Morozov's avatar
Sergei Morozov committed
28
    public function getBindingType(): int
29
    {
30
        return ParameterType::STRING;
31
    }
32

Steve Müller's avatar
Steve Müller committed
33
    /**
34
     * {@inheritdoc}
Steve Müller's avatar
Steve Müller committed
35
     */
36
    public function convertToPHPValue($value, AbstractPlatform $platform)
Steve Müller's avatar
Steve Müller committed
37
    {
38
        return $value === null ? null : (string) $value;
39
    }
Benjamin Eberlei's avatar
Benjamin Eberlei committed
40
}