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

Result::isNotValid()   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
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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