Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
18 / 18
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
6 / 6
CRAP
100.00% covered (success)
100.00%
1 / 1
Review
100.00% covered (success)
100.00%
18 / 18
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
6 / 6
10
100.00% covered (success)
100.00%
1 / 1
 __construct
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
 addError
100.00% covered (success)
100.00%
4 / 4
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
 isList
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
 values
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
 path
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
4
 normalizePath
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace Celema\Sire;
6
7/** @api */
8final readonly class Review
9{
10    /** @param array<array-key, mixed> $values */
11    public function __construct(
12        private ErrorBag $errors,
13        private array $values,
14        private bool $list,
15    ) {}
16
17    /**
18     * @param string|int|list<string|int> $path
19     * @param array<string, mixed> $params
20     */
21    public function addError(
22        string|int|array $path,
23        string $message,
24        string $code = 'custom',
25        array $params = [],
26    ): void {
27        $this->errors->add(
28            self::path($path),
29            new Issue([], $code, $message, $params),
30        );
31    }
32
33    public function isList(): bool
34    {
35        return $this->list;
36    }
37
38    /** @return array<array-key, mixed> */
39    public function values(): array
40    {
41        return $this->values;
42    }
43
44    /**
45     * @param string|int|list<string|int> $path
46     * @return list<string|int>
47     */
48    private static function path(string|int|array $path): array
49    {
50        if (is_int($path)) {
51            return [$path];
52        }
53
54        if (is_string($path)) {
55            if ($path === '') {
56                return [];
57            }
58
59            return self::normalizePath(explode('.', $path));
60        }
61
62        return $path;
63    }
64
65    /**
66     * @param list<string> $path
67     * @return list<string|int>
68     */
69    private static function normalizePath(array $path): array
70    {
71        return array_map(
72            static fn(string $part): string|int => ctype_digit($part) ? (int) $part : $part,
73            $path,
74        );
75    }
76}

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.

Review->__construct
12        private ErrorBag $errors,
13        private array $values,
14        private bool $list,
15    ) {}
Review->addError
22        string|int|array $path,
23        string $message,
24        string $code = 'custom',
25        array $params = [],
26    ): void {
27        $this->errors->add(
28            self::path($path),
29            new Issue([], $code, $message, $params),
30        );
31    }
Review->isList
35        return $this->list;
36    }
Review->normalizePath
69    private static function normalizePath(array $path): array
70    {
71        return array_map(
72            static fn(string $part): string|int => ctype_digit($part) ? (int) $part : $part,
73            $path,
74        );
75    }
Review->path
48    private static function path(string|int|array $path): array
49    {
50        if (is_int($path)) {
51            return [$path];
54        if (is_string($path)) {
55            if ($path === '') {
56                return [];
59            return self::normalizePath(explode('.', $path));
62        return $path;
63    }
Review->values
41        return $this->values;
42    }
{closure:/workspace/celema/sire/src/Review.php:72-72}
72            static fn(string $part): string|int => ctype_digit($part) ? (int) $part : $part,
72            static fn(string $part): string|int => ctype_digit($part) ? (int) $part : $part,
72            static fn(string $part): string|int => ctype_digit($part) ? (int) $part : $part,
72            static fn(string $part): string|int => ctype_digit($part) ? (int) $part : $part,