• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

martin-georgiev / postgresql-for-doctrine / 131a64b22e77224d46cfbb56ee4a8bcb6c7fabda

24 May 2026 11:40PM UTC coverage: 98.701% (-0.07%) from 98.766%
131a64b22e77224d46cfbb56ee4a8bcb6c7fabda

push

github

web-flow
feat: add support for multirange array DBAL types (#634)

198 of 204 new or added lines in 18 files covered. (97.06%)

5320 of 5390 relevant lines covered (98.7%)

36.23 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.45
/src/MartinGeorgiev/Doctrine/DBAL/Types/Int4MultirangeArray.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace MartinGeorgiev\Doctrine\DBAL\Types;
6

7
use MartinGeorgiev\Doctrine\DBAL\Type;
8
use MartinGeorgiev\Doctrine\DBAL\Types\Exceptions\InvalidInt4MultirangeArrayItemForDatabaseException;
9
use MartinGeorgiev\Doctrine\DBAL\Types\Exceptions\InvalidInt4MultirangeArrayItemForPHPException;
10
use MartinGeorgiev\Doctrine\DBAL\Types\ValueObject\Int4Multirange as Int4MultirangeValueObject;
11
use MartinGeorgiev\Utils\PostgresArrayToPHPArrayTransformer;
12

13
/**
14
 * Implementation of PostgreSQL INT4MULTIRANGE[] data type.
15
 *
16
 * @see https://www.postgresql.org/docs/18/rangetypes.html
17
 * @since 4.6
18
 *
19
 * @author Martin Georgiev <martin.georgiev@gmail.com>
20
 */
21
class Int4MultirangeArray extends BaseArray
22
{
23
    /**
24
     * @var string
25
     */
26
    protected const TYPE_NAME = Type::INT4MULTIRANGE_ARRAY;
27

28
    public function isValidArrayItemForDatabase(mixed $item): bool
19✔
29
    {
30
        return $item === null || $item instanceof Int4MultirangeValueObject;
19✔
31
    }
32

33
    protected function transformArrayItemForPostgres(mixed $item): string
9✔
34
    {
35
        if ($item === null) {
9✔
36
            return 'NULL';
2✔
37
        }
38

39
        if (!$item instanceof Int4MultirangeValueObject) {
9✔
NEW
40
            throw InvalidInt4MultirangeArrayItemForDatabaseException::forInvalidType($item);
×
41
        }
42

43
        return $this->quoteAndEscapeArrayItem((string) $item);
9✔
44
    }
45

46
    protected function transformPostgresArrayToPHPArray(string $postgresArray): array
12✔
47
    {
48
        return PostgresArrayToPHPArrayTransformer::transformPostgresArrayToPHPArray($postgresArray);
12✔
49
    }
50

51
    public function transformArrayItemForPHP(mixed $item): ?Int4MultirangeValueObject
12✔
52
    {
53
        if ($item === null) {
12✔
54
            return null;
3✔
55
        }
56

57
        if (!\is_string($item)) {
11✔
58
            throw InvalidInt4MultirangeArrayItemForPHPException::forInvalidType($item);
1✔
59
        }
60

61
        try {
62
            return Int4MultirangeValueObject::fromString($item);
10✔
63
        } catch (\InvalidArgumentException) {
1✔
64
            throw InvalidInt4MultirangeArrayItemForPHPException::forInvalidFormat($item);
1✔
65
        }
66
    }
67

68
    protected function throwInvalidTypeException(mixed $value): never
2✔
69
    {
70
        throw InvalidInt4MultirangeArrayItemForPHPException::forInvalidArrayType($value);
2✔
71
    }
72

73
    protected function throwInvalidItemException(mixed $item): never
3✔
74
    {
75
        throw InvalidInt4MultirangeArrayItemForDatabaseException::forInvalidType($item);
3✔
76
    }
77
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc