Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
85.71% |
6 / 7 |
|
80.00% |
8 / 10 |
|
33.33% |
2 / 6 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| EntitiesAliases | |
85.71% |
6 / 7 |
|
80.00% |
8 / 10 |
|
33.33% |
2 / 6 |
|
50.00% |
1 / 2 |
8.74 | |
0.00% |
0 / 1 |
| __construct | |
83.33% |
5 / 6 |
|
77.78% |
7 / 9 |
|
20.00% |
1 / 5 |
|
0.00% |
0 / 1 |
7.61 | |||
| getAlias | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Specification; |
| 4 | |
| 5 | /** |
| 6 | * @author Wilhelm Zwertvaegher |
| 7 | */ |
| 8 | class EntitiesAliases |
| 9 | { |
| 10 | /** |
| 11 | * @var array<class-string, string> |
| 12 | */ |
| 13 | private readonly array $aliases; |
| 14 | |
| 15 | /** |
| 16 | * @param string ...$args |
| 17 | */ |
| 18 | public function __construct(...$args) |
| 19 | { |
| 20 | $aliases = []; |
| 21 | for ($i = 0; $i < count($args) - 1; $i += 2) { |
| 22 | if (!class_exists($args[$i])) { |
| 23 | throw new \InvalidArgumentException("Class {$args[$i]} does not exist"); |
| 24 | } |
| 25 | $aliases[$args[$i]] = $args[$i + 1]; |
| 26 | } |
| 27 | $this->aliases = $aliases; |
| 28 | } |
| 29 | |
| 30 | public function getAlias(string $class): string |
| 31 | { |
| 32 | return $this->aliases[$class] ?? throw new \InvalidArgumentException("Class {$class} does not exist"); |
| 33 | } |
| 34 | } |
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.
| 18 | public function __construct(...$args) |
| 19 | { |
| 20 | $aliases = []; |
| 21 | for ($i = 0; $i < count($args) - 1; $i += 2) { |
| 22 | if (!class_exists($args[$i])) { |
| 22 | if (!class_exists($args[$i])) { |
| 22 | if (!class_exists($args[$i])) { |
| 22 | if (!class_exists($args[$i])) { |
| 23 | throw new \InvalidArgumentException("Class {$args[$i]} does not exist"); |
| 21 | for ($i = 0; $i < count($args) - 1; $i += 2) { |
| 22 | if (!class_exists($args[$i])) { |
| 23 | throw new \InvalidArgumentException("Class {$args[$i]} does not exist"); |
| 24 | } |
| 25 | $aliases[$args[$i]] = $args[$i + 1]; |
| 21 | for ($i = 0; $i < count($args) - 1; $i += 2) { |
| 27 | $this->aliases = $aliases; |
| 28 | } |
| 30 | public function getAlias(string $class): string |
| 31 | { |
| 32 | return $this->aliases[$class] ?? throw new \InvalidArgumentException("Class {$class} does not exist"); |
| 33 | } |
| 3 | namespace App\Specification; |
| 4 | |
| 5 | /** |
| 6 | * @author Wilhelm Zwertvaegher |
| 7 | */ |
| 8 | class EntitiesAliases |
| 9 | { |
| 10 | /** |
| 11 | * @var array<class-string, string> |
| 12 | */ |
| 13 | private readonly array $aliases; |
| 14 | |
| 15 | /** |
| 16 | * @param string ...$args |
| 17 | */ |
| 18 | public function __construct(...$args) |
| 19 | { |
| 20 | $aliases = []; |
| 21 | for ($i = 0; $i < count($args) - 1; $i += 2) { |
| 22 | if (!class_exists($args[$i])) { |
| 23 | throw new \InvalidArgumentException("Class {$args[$i]} does not exist"); |
| 24 | } |
| 25 | $aliases[$args[$i]] = $args[$i + 1]; |
| 26 | } |
| 27 | $this->aliases = $aliases; |
| 28 | } |
| 29 | |
| 30 | public function getAlias(string $class): string |
| 31 | { |
| 32 | return $this->aliases[$class] ?? throw new \InvalidArgumentException("Class {$class} does not exist"); |
| 33 | } |