Completed
Push — master ( 6630f6...b334d3 )
by Albert
05:18
created

Verdict   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 58
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 4 1
A __construct() 0 6 1
A passes() 0 4 1
A getField() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Albert221\Validation;
6
7
use Albert221\Validation\Rule\Rule;
8
9
class Verdict
10
{
11
    /**
12
     * @var bool
13
     */
14
    private $passes;
15
16
    /**
17
     * @var Rule
18
     */
19
    private $rule;
20
21
    /**
22
     * @var Field
23
     */
24
    private $field;
25
26
    /**
27
     * @param bool $passes
28
     * @param Rule $rule
29
     *
30
     * @return Verdict
31
     */
32
    public static function create(bool $passes, Rule $rule)
33
    {
34
        return new self($passes, $rule, $rule->getField());
35
    }
36
37
    /**
38
     * Verdict constructor.
39
     *
40
     * @param bool $passes
41
     * @param Rule $rule
42
     * @param Field $field
43
     */
44
    public function __construct(bool $passes, Rule $rule, Field $field)
45
    {
46
        $this->passes = $passes;
47
        $this->rule = $rule;
48
        $this->field = $field;
49
    }
50
51
    /**
52
     * @return bool
53
     */
54
    public function passes(): bool
55
    {
56
        return $this->passes;
57
    }
58
59
    /**
60
     * @return Field
61
     */
62
    public function getField(): Field
63
    {
64
        return $this->field;
65
    }
66
}
67