Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
13 / 13
53.33% covered (warning)
53.33%
8 / 15
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
DefaultCoercers
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
13 / 13
53.33% covered (warning)
53.33%
8 / 15
100.00% covered (success)
100.00%
1 / 1
20.16
100.00% covered (success)
100.00%
1 / 1
 get
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
13 / 13
53.33% covered (warning)
53.33%
8 / 15
100.00% covered (success)
100.00%
1 / 1
20.16
1<?php
2
3declare(strict_types=1);
4
5namespace Celemas\Sire;
6
7use Override;
8
9final class DefaultCoercers implements Contract\CoercerRegistry
10{
11    /** @var array<string, Contract\Coercer> */
12    private array $loaded = [];
13
14    #[Override]
15    public function get(string $name): ?Contract\Coercer
16    {
17        if (array_key_exists($name, $this->loaded)) {
18            return $this->loaded[$name];
19        }
20
21        $coercer = match ($name) {
22            'string' => new Coercer\Str(),
23            'bool' => new Coercer\Boolean(),
24            'list' => new Coercer\ListArray(),
25            'float' => new Coercer\FloatingPoint(),
26            'int' => new Coercer\Integer(),
27            'number' => new Coercer\Number(),
28            default => null,
29        };
30
31        if ($coercer !== null) {
32            $this->loaded[$name] = $coercer;
33        }
34
35        return $coercer;
36    }
37}

Paths

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

DefaultCoercers->get
15    public function get(string $name): ?Contract\Coercer
16    {
17        if (array_key_exists($name, $this->loaded)) {
 
18            return $this->loaded[$name];
15    public function get(string $name): ?Contract\Coercer
16    {
17        if (array_key_exists($name, $this->loaded)) {
 
21        $coercer = match ($name) {
 
22            'string' => new Coercer\Str(),
 
21        $coercer = match ($name) {
22            'string' => new Coercer\Str(),
23            'bool' => new Coercer\Boolean(),
24            'list' => new Coercer\ListArray(),
25            'float' => new Coercer\FloatingPoint(),
26            'int' => new Coercer\Integer(),
27            'number' => new Coercer\Number(),
28            default => null,
29        };
30
31        if ($coercer !== null) {
 
32            $this->loaded[$name] = $coercer;
33        }
34
35        return $coercer;
 
35        return $coercer;
36    }
15    public function get(string $name): ?Contract\Coercer
16    {
17        if (array_key_exists($name, $this->loaded)) {
 
21        $coercer = match ($name) {
 
22            'string' => new Coercer\Str(),
 
21        $coercer = match ($name) {
22            'string' => new Coercer\Str(),
23            'bool' => new Coercer\Boolean(),
24            'list' => new Coercer\ListArray(),
25            'float' => new Coercer\FloatingPoint(),
26            'int' => new Coercer\Integer(),
27            'number' => new Coercer\Number(),
28            default => null,
29        };
30
31        if ($coercer !== null) {
 
35        return $coercer;
36    }
15    public function get(string $name): ?Contract\Coercer
16    {
17        if (array_key_exists($name, $this->loaded)) {
 
21        $coercer = match ($name) {
 
23            'bool' => new Coercer\Boolean(),
 
21        $coercer = match ($name) {
22            'string' => new Coercer\Str(),
23            'bool' => new Coercer\Boolean(),
24            'list' => new Coercer\ListArray(),
25            'float' => new Coercer\FloatingPoint(),
26            'int' => new Coercer\Integer(),
27            'number' => new Coercer\Number(),
28            default => null,
29        };
30
31        if ($coercer !== null) {
 
32            $this->loaded[$name] = $coercer;
33        }
34
35        return $coercer;
 
35        return $coercer;
36    }
15    public function get(string $name): ?Contract\Coercer
16    {
17        if (array_key_exists($name, $this->loaded)) {
 
21        $coercer = match ($name) {
 
23            'bool' => new Coercer\Boolean(),
 
21        $coercer = match ($name) {
22            'string' => new Coercer\Str(),
23            'bool' => new Coercer\Boolean(),
24            'list' => new Coercer\ListArray(),
25            'float' => new Coercer\FloatingPoint(),
26            'int' => new Coercer\Integer(),
27            'number' => new Coercer\Number(),
28            default => null,
29        };
30
31        if ($coercer !== null) {
 
35        return $coercer;
36    }
15    public function get(string $name): ?Contract\Coercer
16    {
17        if (array_key_exists($name, $this->loaded)) {
 
21        $coercer = match ($name) {
 
24            'list' => new Coercer\ListArray(),
 
21        $coercer = match ($name) {
22            'string' => new Coercer\Str(),
23            'bool' => new Coercer\Boolean(),
24            'list' => new Coercer\ListArray(),
25            'float' => new Coercer\FloatingPoint(),
26            'int' => new Coercer\Integer(),
27            'number' => new Coercer\Number(),
28            default => null,
29        };
30
31        if ($coercer !== null) {
 
32            $this->loaded[$name] = $coercer;
33        }
34
35        return $coercer;
 
35        return $coercer;
36    }
15    public function get(string $name): ?Contract\Coercer
16    {
17        if (array_key_exists($name, $this->loaded)) {
 
21        $coercer = match ($name) {
 
24            'list' => new Coercer\ListArray(),
 
21        $coercer = match ($name) {
22            'string' => new Coercer\Str(),
23            'bool' => new Coercer\Boolean(),
24            'list' => new Coercer\ListArray(),
25            'float' => new Coercer\FloatingPoint(),
26            'int' => new Coercer\Integer(),
27            'number' => new Coercer\Number(),
28            default => null,
29        };
30
31        if ($coercer !== null) {
 
35        return $coercer;
36    }
15    public function get(string $name): ?Contract\Coercer
16    {
17        if (array_key_exists($name, $this->loaded)) {
 
21        $coercer = match ($name) {
 
25            'float' => new Coercer\FloatingPoint(),
 
21        $coercer = match ($name) {
22            'string' => new Coercer\Str(),
23            'bool' => new Coercer\Boolean(),
24            'list' => new Coercer\ListArray(),
25            'float' => new Coercer\FloatingPoint(),
26            'int' => new Coercer\Integer(),
27            'number' => new Coercer\Number(),
28            default => null,
29        };
30
31        if ($coercer !== null) {
 
32            $this->loaded[$name] = $coercer;
33        }
34
35        return $coercer;
 
35        return $coercer;
36    }
15    public function get(string $name): ?Contract\Coercer
16    {
17        if (array_key_exists($name, $this->loaded)) {
 
21        $coercer = match ($name) {
 
25            'float' => new Coercer\FloatingPoint(),
 
21        $coercer = match ($name) {
22            'string' => new Coercer\Str(),
23            'bool' => new Coercer\Boolean(),
24            'list' => new Coercer\ListArray(),
25            'float' => new Coercer\FloatingPoint(),
26            'int' => new Coercer\Integer(),
27            'number' => new Coercer\Number(),
28            default => null,
29        };
30
31        if ($coercer !== null) {
 
35        return $coercer;
36    }
15    public function get(string $name): ?Contract\Coercer
16    {
17        if (array_key_exists($name, $this->loaded)) {
 
21        $coercer = match ($name) {
 
26            'int' => new Coercer\Integer(),
 
21        $coercer = match ($name) {
22            'string' => new Coercer\Str(),
23            'bool' => new Coercer\Boolean(),
24            'list' => new Coercer\ListArray(),
25            'float' => new Coercer\FloatingPoint(),
26            'int' => new Coercer\Integer(),
27            'number' => new Coercer\Number(),
28            default => null,
29        };
30
31        if ($coercer !== null) {
 
32            $this->loaded[$name] = $coercer;
33        }
34
35        return $coercer;
 
35        return $coercer;
36    }
15    public function get(string $name): ?Contract\Coercer
16    {
17        if (array_key_exists($name, $this->loaded)) {
 
21        $coercer = match ($name) {
 
26            'int' => new Coercer\Integer(),
 
21        $coercer = match ($name) {
22            'string' => new Coercer\Str(),
23            'bool' => new Coercer\Boolean(),
24            'list' => new Coercer\ListArray(),
25            'float' => new Coercer\FloatingPoint(),
26            'int' => new Coercer\Integer(),
27            'number' => new Coercer\Number(),
28            default => null,
29        };
30
31        if ($coercer !== null) {
 
35        return $coercer;
36    }
15    public function get(string $name): ?Contract\Coercer
16    {
17        if (array_key_exists($name, $this->loaded)) {
 
21        $coercer = match ($name) {
 
27            'number' => new Coercer\Number(),
 
21        $coercer = match ($name) {
22            'string' => new Coercer\Str(),
23            'bool' => new Coercer\Boolean(),
24            'list' => new Coercer\ListArray(),
25            'float' => new Coercer\FloatingPoint(),
26            'int' => new Coercer\Integer(),
27            'number' => new Coercer\Number(),
28            default => null,
29        };
30
31        if ($coercer !== null) {
 
32            $this->loaded[$name] = $coercer;
33        }
34
35        return $coercer;
 
35        return $coercer;
36    }
15    public function get(string $name): ?Contract\Coercer
16    {
17        if (array_key_exists($name, $this->loaded)) {
 
21        $coercer = match ($name) {
 
27            'number' => new Coercer\Number(),
 
21        $coercer = match ($name) {
22            'string' => new Coercer\Str(),
23            'bool' => new Coercer\Boolean(),
24            'list' => new Coercer\ListArray(),
25            'float' => new Coercer\FloatingPoint(),
26            'int' => new Coercer\Integer(),
27            'number' => new Coercer\Number(),
28            default => null,
29        };
30
31        if ($coercer !== null) {
 
35        return $coercer;
36    }
15    public function get(string $name): ?Contract\Coercer
16    {
17        if (array_key_exists($name, $this->loaded)) {
 
21        $coercer = match ($name) {
 
28            default => null,
 
21        $coercer = match ($name) {
22            'string' => new Coercer\Str(),
23            'bool' => new Coercer\Boolean(),
24            'list' => new Coercer\ListArray(),
25            'float' => new Coercer\FloatingPoint(),
26            'int' => new Coercer\Integer(),
27            'number' => new Coercer\Number(),
28            default => null,
29        };
30
31        if ($coercer !== null) {
 
32            $this->loaded[$name] = $coercer;
33        }
34
35        return $coercer;
 
35        return $coercer;
36    }
15    public function get(string $name): ?Contract\Coercer
16    {
17        if (array_key_exists($name, $this->loaded)) {
 
21        $coercer = match ($name) {
 
28            default => null,
 
21        $coercer = match ($name) {
22            'string' => new Coercer\Str(),
23            'bool' => new Coercer\Boolean(),
24            'list' => new Coercer\ListArray(),
25            'float' => new Coercer\FloatingPoint(),
26            'int' => new Coercer\Integer(),
27            'number' => new Coercer\Number(),
28            default => null,
29        };
30
31        if ($coercer !== null) {
 
35        return $coercer;
36    }