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

Error   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 27
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getStringValuePath() 0 3 1
A __construct() 0 4 1
A getValuePath() 0 3 1
A getMessage() 0 3 1
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