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

tylernathanreed / jira-client-php / 13634221961

03 Mar 2025 03:19PM UTC coverage: 2.067% (-0.1%) from 2.21%
13634221961

push

github

web-flow
~ Try coveralls action

140 of 6773 relevant lines covered (2.07%)

0.06 hits per line

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

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

3
namespace Jira\Client;
4

5
use InvalidArgumentException;
6

7
abstract readonly class PolymorphicDto extends Dto
8
{
9
    abstract public static function discriminator(): string;
×
10

11
    /** @return array<string,class-string<Dto>> */
12
    abstract public static function discriminatorMap(): array;
×
13

14
    /** @return class-string<Dto> */
15
    public static function discriminate(string $discriminator): string
×
16
    {
17
        $type = static::discriminatorMap()[$discriminator] ?? null;
×
18

19
        if (is_null($type)) {
×
20
            throw new InvalidArgumentException(sprintf(
×
21
                'Could not find [%s] mapping for [%s].',
×
22
                static::class,
×
23
                $type
×
24
            ));
×
25
        }
26

27
        return $type;
×
28
    }
29

30
    /**
31
     * @param array<string,mixed> $data
32
     *
33
     * @return class-string<Dto>
34
     */
35
    public static function discriminateFromData(array $data): string
×
36
    {
37
        $discriminator = $data[static::discriminator()] ?? null;
×
38

39
        if (is_null($discriminator)) {
×
40
            throw new InvalidArgumentException(sprintf(
×
41
                'Could not find [%s] discriminator.',
×
42
                static::class,
×
43
            ));
×
44
        }
45

46
        if (! is_string($discriminator)) {
×
47
            throw new InvalidArgumentException(sprintf(
×
48
                'Discriminator for [%s] is not a string.',
×
49
                static::class,
×
50
            ));
×
51
        }
52

53
        return static::discriminate($discriminator);
×
54
    }
55
}
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