Completed
Push — master ( 14565d...9435d2 )
by Shcherbak
09:17
created

ValidationResult   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 81.82%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 32
ccs 9
cts 11
cp 0.8182
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A merge() 0 6 2
A addError() 0 4 1
A getErrors() 0 3 1
A isValid() 0 3 1
1
<?php
2
3
  declare(strict_types=1);
4
5
  namespace Fiv\Form\Validator;
6
7
  class ValidationResult implements ValidationResultInterface {
8
9
    /**
10
     * @var string[]
11
     */
12
    private $errors = [];
13
14
15 2
    public function merge(ValidationResult $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
  }