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

strictlyPHP / domantra / #7

23 Dec 2025 08:02PM UTC coverage: 96.656% (+0.03%) from 96.629%
#7

push

web-flow
Merge pull request #20 from strictlyPHP/add-role-based-masking

add role based property removal

49 of 49 new or added lines in 8 files covered. (100.0%)

1 existing line in 1 file now uncovered.

289 of 299 relevant lines covered (96.66%)

2.5 hits per line

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

86.96
/src/Cache/AbstractDtoCacheHandler.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace StrictlyPHP\Domantra\Cache;
6

7
abstract class AbstractDtoCacheHandler implements DtoCacheHandlerInterface
8
{
9
    /**
10
     * @param class-string $class
11
     */
12
    protected function getKey(
13
        string $cacheKey,
14
        string $class,
15
        ?string $version = null
16
    ): string {
17
        if (! $version) {
3✔
18
            $version = $this->fingerprintClassProperties($class);
3✔
19
        }
20

21
        return sprintf(
3✔
22
            '%s:%s:%s:%s',
3✔
23
            'resource-key',
3✔
24
            str_replace('\\', '/', $class),
3✔
25
            $cacheKey,
3✔
26
            $version
3✔
27
        );
3✔
28
    }
29

30
    /**
31
     * @param class-string $class
32
     */
33
    protected function fingerprintClassProperties(string $class): string
34
    {
35
        $ref = new \ReflectionClass($class);
3✔
36
        $properties = [];
3✔
37

38
        foreach ($ref->getProperties() as $prop) {
3✔
39
            $type = $prop->getType();
3✔
40
            $typeName = '';
3✔
41

42
            if ($type instanceof \ReflectionNamedType) {
3✔
43
                $typeName = ($type->allowsNull() ? '?' : '') . $type->getName();
3✔
UNCOV
44
            } elseif ($type instanceof \ReflectionUnionType) {
×
45
                $typeName = ($type->allowsNull() ? '?' : '') .
×
46
                    implode('|', array_map(fn ($t) => $t->getName(), $type->getTypes()));
×
47
            }
48

49
            $properties[$prop->getName()] = $typeName;
3✔
50
        }
51

52
        ksort($properties); // Sort keys for consistent hashing
3✔
53
        $json = json_encode($properties, JSON_UNESCAPED_UNICODE);
3✔
54

55
        return hash('sha256', $json);
3✔
56
    }
57
}
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