Passed
Pull Request — master (#140)
by
unknown
02:10
created

Result   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 28
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A isValid() 0 3 1
A isNotValid() 0 3 1
A getErrors() 0 3 1
A addError() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator;
6
7
final class Result
8
{
9
    /**
10
     * @psalm-var list<string>
11
     */
12
    private array $errors = [];
13
14 156
    public function isValid(): bool
15
    {
16 156
        return $this->errors === [];
17
    }
18
19 40
    public function isNotValid(): bool
20
    {
21 40
        return $this->isValid() === false;
22
    }
23
24 127
    public function addError(string $message): void
25
    {
26 127
        $this->errors[] = $message;
27 127
    }
28
29
    /**
30
     * @psalm-return list<string>
31
     */
32 35
    public function getErrors(): array
33
    {
34 35
        return $this->errors;
35
    }
36
}
37