Test Failed
Pull Request — master (#151)
by
unknown
02:21
created

Error::getMessage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator;
6
7
final class Error
8
{
9
    private string $message;
10
    private ?array $valuePath;
11
12
    public function __construct(string $message, ?array $valuePath = null)
13
    {
14
        $this->message = $message;
15
        $this->valuePath = $valuePath;
16
    }
17
18
    public function getMessage(): string
19
    {
20
        return $this->message;
21
    }
22
23
    /**
24
     * @psalm-var array<int|string>
25
     */
26
    public function getValuePath(): array
27
    {
28
        return $this->valuePath;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->valuePath could return the type null which is incompatible with the type-hinted return array. Consider adding an additional type-check to rule them out.
Loading history...
29
    }
30
31
    public function getStringValuePath(): string
32
    {
33
        return implode('.', $this->valuePath);
0 ignored issues
show
Bug introduced by
It seems like $this->valuePath can also be of type null; however, parameter $pieces of implode() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

33
        return implode('.', /** @scrutinizer ignore-type */ $this->valuePath);
Loading history...
34
    }
35
}
36