ValidationResult   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
c 2
b 0
f 0
dl 0
loc 30
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A isOk() 0 3 1
A error() 0 4 1
A getErrors() 0 3 1
A everythingIsOk() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace BrenoRoosevelt\Validation;
5
6
class ValidationResult implements Result
7
{
8
    /** @var string[] */
9
    private array $errors = [];
10
11
    public static function everythingIsOk(): self
12
    {
13
        return new self;
14
    }
15
16
    public function error(string ...$errors): self
17
    {
18
        array_push($this->errors, ...$errors);
19
        return $this;
20
    }
21
22
    /**
23
     * @inheritDoc
24
     */
25
    public function isOk(): bool
26
    {
27
        return empty($this->errors);
28
    }
29
30
    /**
31
     * @inheritDoc
32
     */
33
    public function getErrors(): array
34
    {
35
        return $this->errors;
36
    }
37
}
38