Completed
Push — master ( 2811d3...4b37a8 )
by Shcherbak
11:11
created

ValidationResult::addError()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
  declare(strict_types=1);
4
5
  namespace Fiv\Form\Validation;
6
7
  class ValidationResult implements ValidationResultInterface {
8
9
    /**
10
     * @var string[]
11
     */
12
    private $errors = [];
13
14
15 2
    public function merge(ValidationResultInterface $validationResult) : self {
16 2
      foreach ($validationResult->getErrors() as $error) {
17 1
        $this->addError($error);
18
      }
19 2
      return $this;
20
    }
21
22
23 1
    public function addError(string $error) : self {
24 1
      $this->errors[] = $error;
25 1
      return $this;
26
    }
27
28
29 2
    public function getErrors() {
30 2
      return $this->errors;
31
    }
32
33
34
    public function isValid() : bool {
35
      return empty($this->errors);
36
    }
37
38
  }