ValidationResult::addError()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
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