Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
GrammaticalRoleType
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
2 / 2
5
100.00% covered (success)
100.00%
1 / 1
 fromClass
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
4
 fromString
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Enum;
4
5use App\Entity\Qualifier;
6use App\Entity\Subject;
7
8/**
9 * @author Wilhelm Zwertvaegher
10 */
11enum GrammaticalRoleType: string implements Enum
12{
13    case SUBJECT = 'subject';
14    case QUALIFIER = 'qualifier';
15
16    /**
17     * @param class-string $className
18     */
19    public static function fromClass(string $className): GrammaticalRoleType
20    {
21        return match ($className) {
22            Subject::class => self::SUBJECT,
23            Qualifier::class => self::QUALIFIER,
24            default => throw new \InvalidArgumentException('Unknown class: '.$className),
25        };
26    }
27
28    public static function fromString(string $value): Enum
29    {
30        return self::from($value);
31    }
32}

Branches

Below are the source code lines that represent each code branch as identified by Xdebug. Please note a branch is not necessarily coterminous with a line, a line may contain multiple branches and therefore show up more than once. Please also be aware that some branches may be implicit rather than explicit, e.g. an if statement always has an else as part of its logical flow even if you didn't write one.

GrammaticalRoleType->fromClass
19    public static function fromClass(string $className): GrammaticalRoleType
20    {
21        return match ($className) {
22            Subject::class => self::SUBJECT,
23            Qualifier::class => self::QUALIFIER,
24            default => throw new \InvalidArgumentException('Unknown class: '.$className),
24            default => throw new \InvalidArgumentException('Unknown class: '.$className),
25        };
26    }
GrammaticalRoleType->fromString
28    public static function fromString(string $value): Enum
29    {
30        return self::from($value);
31    }