Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
50.00% covered (danger)
50.00%
3 / 6
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
case_insensitive_string
50.00% covered (danger)
50.00%
3 / 6
0.00% covered (danger)
0.00%
0 / 2
6.00
0.00% covered (danger)
0.00%
0 / 1
 getSQLDeclaration
60.00% covered (warning)
60.00%
3 / 5
0.00% covered (danger)
0.00%
0 / 1
3.58
 getName
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 *
4 * This file is part of the phpBB Forum Software package.
5 *
6 * @copyright (c) phpBB Limited <https://www.phpbb.com>
7 * @license GNU General Public License, version 2 (GPL-2.0)
8 *
9 * For full copyright and license information, please see
10 * the docs/CREDITS.txt file.
11 *
12 */
13
14namespace phpbb\db\doctrine;
15
16use Doctrine\DBAL\Platforms\AbstractPlatform;
17use Doctrine\DBAL\Types\Type;
18use phpbb\db\middleware\oracle\platform as oracle_platform;
19use phpbb\db\middleware\postgresql\platform as postgresql_platform;
20
21/**
22 * Case-insensitive string type (only supported by Postgres).
23 */
24class case_insensitive_string extends Type
25{
26    public const CASE_INSENSITIVE_STRING = 'string_ci';
27
28    /**
29     * {@inheritdoc}
30     */
31    public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
32    {
33        if ($platform instanceof postgresql_platform)
34        {
35            return 'varchar_ci';
36        }
37
38        // This relies on our own oracle_platform implementation, and the fact that
39        // we used 3 times larger capacity for strings on oracle for unicode strings
40        // as on other platforms. This is not the case with varchar_ci, which uses
41        // the same length as other platforms.
42        if ($platform instanceof oracle_platform)
43        {
44            return $platform->getAsciiStringTypeDeclarationSQL($column);
45        }
46
47        return $platform->getVarcharTypeDeclarationSQL($column);
48    }
49
50    /**
51     * {@inheritdoc}
52     */
53    public function getName(): string
54    {
55        return self::CASE_INSENSITIVE_STRING;
56    }
57}