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

tito10047 / type-safe-id-bundle / 23111581820

15 Mar 2026 01:42PM UTC coverage: 69.912%. First build
23111581820

Pull #1

github

tito10047
try fix CI
Pull Request #1: Test

11 of 36 new or added lines in 4 files covered. (30.56%)

79 of 113 relevant lines covered (69.91%)

2.01 hits per line

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

6.67
/src/AbstractIntIdType.php
1
<?php
2

3
namespace Tito10047\TypeSafeIdBundle;
4

5
use Doctrine\DBAL\Platforms\AbstractPlatform;
6
use Doctrine\DBAL\Types\Type;
7

8
/**
9
 * Abstract Doctrine type for IntId-based identifiers.
10
 * Similar to AbstractUidType but for integer-based IDs.
11
 */
12
abstract class AbstractIntIdType extends Type
13
{
14
    /**
15
     * Returns the IntId class that this type handles.
16
     */
17
    abstract protected function getIntIdClass(): string;
18

19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
23
    {
24
        return $platform->getIntegerTypeDeclarationSQL($column);
1✔
25
    }
26

27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function convertToPHPValue($value, AbstractPlatform $platform): ?IntId
31
    {
NEW
32
        if ($value === null || $value === '') {
×
NEW
33
            return null;
×
34
        }
35

NEW
36
        if ($value instanceof IntId) {
×
NEW
37
            return $value;
×
38
        }
39

NEW
40
        $class = $this->getIntIdClass();
×
41

42
        try {
NEW
43
            return $class::fromInt((int) $value);
×
NEW
44
        } catch (\Exception $e) {
×
NEW
45
            throw new \RuntimeException(sprintf('Could not convert database value "%s" to IntId: %s', $value, $e->getMessage()), 0, $e);
×
46
        }
47
    }
48

49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function convertToDatabaseValue($value, AbstractPlatform $platform): ?int
53
    {
NEW
54
        if ($value === null || $value === '') {
×
NEW
55
            return null;
×
56
        }
57

NEW
58
        if ($value instanceof IntId) {
×
NEW
59
            return $value->toInt();
×
60
        }
61

NEW
62
        throw new \InvalidArgumentException(sprintf('Expected instance of %s, got %s', $this->getIntIdClass(), get_debug_type($value)));
×
63
    }
64

65
    /**
66
     * {@inheritdoc}
67
     */
68
    public function requiresSQLCommentHint(AbstractPlatform $platform): bool
69
    {
NEW
70
        return true;
×
71
    }
72
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc