ValidationResult   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 23
ccs 7
cts 7
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getErrors() 0 3 1
A addError() 0 5 1
A passes() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace PrinsFrank\PhpStrictModels\Validation;
5
6
class ValidationResult
7
{
8
    /** @var string[] */
9
    private array $errors = [];
10
11 1
    public function addError(string $error): self
12
    {
13 1
        $this->errors[] = $error;
14
15 1
        return $this;
16
    }
17
18 1
    public function passes(): bool
19
    {
20 1
        return count($this->errors) === 0;
21
    }
22
23
    /**
24
     * @return string[]
25
     */
26 1
    public function getErrors(): array
27
    {
28 1
        return $this->errors;
29
    }
30
}
31