• 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

0.0
/src/IntId.php
1
<?php
2

3
namespace Tito10047\TypeSafeIdBundle;
4

5
use Stringable;
6

7
/**
8
 * Integer ID wrapper class for type-safe entity identifiers.
9
 * Similar to Symfony's Uuid and Ulid, but wraps an integer value.
10
 */
11
abstract class IntId implements \JsonSerializable, Stringable
12
{
13
    protected ?int $id = null;
14

15
    /**
16
     * Creates a new IntId instance.
17
     * For auto-increment IDs, the ID is null until persisted.
18
     */
19
    public function __construct(?int $id = null)
20
    {
NEW
21
        $this->id = $id;
×
22
    }
23

24
    /**
25
     * Creates an IntId from a string representation.
26
     */
27
    public static function fromString(string $id): static
28
    {
NEW
29
        return new static((int) $id);
×
30
    }
31

32
    /**
33
     * Creates an IntId from an integer.
34
     */
35
    public static function fromInt(int $id): static
36
    {
NEW
37
        return new static($id);
×
38
    }
39

40
    /**
41
     * Returns the integer value.
42
     */
43
    public function toInt(): ?int
44
    {
NEW
45
        return $this->id;
×
46
    }
47

48
    /**
49
     * Returns the string representation of the ID.
50
     */
51
    public function toString(): string
52
    {
NEW
53
        return (string) $this->id;
×
54
    }
55

56
    /**
57
     * Returns the string representation of the ID.
58
     */
59
    public function __toString(): string
60
    {
NEW
61
        return $this->toString();
×
62
    }
63

64
    /**
65
     * Returns the ID value for JSON serialization.
66
     */
67
    public function jsonSerialize(): ?int
68
    {
NEW
69
        return $this->id;
×
70
    }
71

72
    /**
73
     * Checks if the ID is valid (not null).
74
     */
75
    public function isValid(): bool
76
    {
NEW
77
        return $this->id !== null;
×
78
    }
79

80
    /**
81
     * Checks if two IDs are equal.
82
     */
83
    public function equals(?self $other): bool
84
    {
NEW
85
        if ($other === null) {
×
NEW
86
            return false;
×
87
        }
88

NEW
89
        return $this->id === $other->id;
×
90
    }
91
}
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