Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
50.00% |
3 / 6 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
case_insensitive_string | |
50.00% |
3 / 6 |
|
0.00% |
0 / 2 |
6.00 | |
0.00% |
0 / 1 |
getSQLDeclaration | |
60.00% |
3 / 5 |
|
0.00% |
0 / 1 |
3.58 | |||
getName | |
0.00% |
0 / 1 |
|
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 | |
14 | namespace phpbb\db\doctrine; |
15 | |
16 | use Doctrine\DBAL\Platforms\AbstractPlatform; |
17 | use Doctrine\DBAL\Types\Type; |
18 | |
19 | /** |
20 | * Case-insensitive string type (only supported by Postgres). |
21 | */ |
22 | class case_insensitive_string extends Type |
23 | { |
24 | public const CASE_INSENSITIVE_STRING = 'string_ci'; |
25 | |
26 | /** |
27 | * {@inheritdoc} |
28 | */ |
29 | public function getSQLDeclaration(array $column, AbstractPlatform $platform): string |
30 | { |
31 | if ($platform instanceof postgresql_platform) |
32 | { |
33 | return 'varchar_ci'; |
34 | } |
35 | |
36 | // This relies on our own oracle_platform implementation, and the fact that |
37 | // we used 3 times larger capacity for strings on oracle for unicode strings |
38 | // as on other platforms. This is not the case with varchar_ci, which uses |
39 | // the same length as other platforms. |
40 | if ($platform instanceof oracle_platform) |
41 | { |
42 | return $platform->getAsciiStringTypeDeclarationSQL($column); |
43 | } |
44 | |
45 | return $platform->getVarcharTypeDeclarationSQL($column); |
46 | } |
47 | |
48 | /** |
49 | * {@inheritdoc} |
50 | */ |
51 | public function getName(): string |
52 | { |
53 | return self::CASE_INSENSITIVE_STRING; |
54 | } |
55 | } |