Passed
Push — master ( 0ce3b5...f76703 )
by Dawid
03:41
created

ValidationResult::getViolations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiechu\SymfonyCommonsBundle\Service;
6
7
class ValidationResult
8
{
9
    /**
10
     * @var ValidationViolation[]
11
     */
12
    protected $errors = [];
13
14 1
    public function addViolation(ValidationViolation $validationViolation): self
15
    {
16 1
        $this->errors[] = $validationViolation;
17
18 1
        return $this;
19
    }
20
21 1
    public function isValid(): bool
22
    {
23 1
        return !count($this->errors);
24
    }
25
26
    /**
27
     * @return ValidationViolation[]
28
     */
29
    public function getViolations(): array
30
    {
31
        return $this->errors;
32
    }
33
}
34