ValidationResult   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A isValid() 0 3 1
A addError() 0 3 1
A getPath() 0 3 1
A getErrors() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace Diezz\YamlToObjectMapper;
4
5
class ValidationResult
6
{
7
    private array $errors = [];
8
9
    public function addError(array $path, $errorMessage): void
10
    {
11
        $this->errors[$this->getPath($path)] = $errorMessage;
12
    }
13
14
    public function isValid(): bool
15
    {
16
        return empty($this->errors);
17
    }
18
19
    /**
20
     * @return array
21
     */
22
    public function getErrors(): array
23
    {
24
        return $this->errors;
25
    }
26
27
    private function getPath(array $path): string
28
    {
29
        return implode(".", $path);
30
    }
31
}
32