Passed
Push — master ( 5c2907...37dc07 )
by Sergei
24:35 queued 21:56
created

Error::getParameters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator;
6
7
final class Error
8
{
9
    /**
10
     * @psalm-param list<int|string> $valuePath
11
     */
12 384
    public function __construct(
13
        private string $message,
14
15
        /**
16
         * @psalm-var array<string,scalar|null>
17
         */
18
        private array $parameters = [],
19
20
        /**
21
         * @psalm-var list<int|string>
22
         */
23
        private array $valuePath = [],
24
    ) {
25
    }
26
27 380
    public function getMessage(): string
28
    {
29 380
        return $this->message;
30
    }
31
32
    /**
33
     * @psalm-return array<string,scalar|null>
34
     */
35 373
    public function getParameters(): array
36
    {
37 373
        return $this->parameters;
38
    }
39
40
    /**
41
     * @psalm-return list<int|string>
42
     */
43 382
    public function getValuePath(bool $escape = false): array
44
    {
45 382
        if ($escape === false) {
46 380
            return $this->valuePath;
47
        }
48
49 314
        return array_map(
50 314
            static fn ($key): string => str_replace(['.', '*'], ['\\' . '.', '\\' . '*'], (string) $key),
51 314
            $this->valuePath
52
        );
53
    }
54
}
55