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

tito10047 / type-safe-id-bundle / 23164628533

16 Mar 2026 08:31PM UTC coverage: 78.621% (-3.8%) from 82.443%
23164628533

push

github

tito10047
change multiple servises to one global

15 of 21 new or added lines in 3 files covered. (71.43%)

2 existing lines in 1 file now uncovered.

114 of 145 relevant lines covered (78.62%)

24.29 hits per line

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

45.45
/src/IdGenerator/UniversalTypeIdGenerator.php
1
<?php
2

3
namespace Tito10047\TypeSafeIdBundle\IdGenerator;
4

5
use Doctrine\ORM\EntityManager;
6
use Doctrine\ORM\EntityManagerInterface;
7
use Doctrine\ORM\Id\AbstractIdGenerator;
8
use Tito10047\TypeSafeIdBundle\GeneratableId;
9

10
final class UniversalTypeIdGenerator extends AbstractIdGenerator
11
{
12
    /** @var array<class-string, class-string<GeneratableId>> */
13
    private array $entityToIdClassMap;
14

15
    /**
16
     * @param array<class-string, class-string<GeneratableId>> $entityToIdClassMap
17
     */
18
    public function __construct(array $entityToIdClassMap)
19
    {
20
        $this->entityToIdClassMap = $entityToIdClassMap;
24✔
21
    }
22

23
    /**
24
     * doctrine/orm < 2.11 BC layer.
25
     */
26
    public function generate(EntityManager $em, $entity): mixed
27
    {
NEW
28
        return $this->generateId($em, $entity);
×
29
    }
30

31
    public function generateId(EntityManagerInterface $em, $entity): GeneratableId
32
    {
33
        $entityClass = $entity::class;
12✔
34

35
        if (!isset($this->entityToIdClassMap[$entityClass])) {
12✔
NEW
36
            throw new \LogicException(sprintf(
×
NEW
37
                'No ID class mapped for entity "%s". Available mappings: %s',
×
NEW
38
                $entityClass,
×
NEW
39
                implode(', ', array_keys($this->entityToIdClassMap))
×
NEW
40
            ));
×
41
        }
42

43
        $idClass = $this->entityToIdClassMap[$entityClass];
12✔
44
        return $idClass::new();
12✔
45
    }
46
}
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