Completed
Push — master ( a67e7e...95640a )
by Tomasz
02:42
created

StructureField::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 5
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Hop\Validator\Strategy;
6
7
final class StructureField implements FieldInterface
8
{
9
    /**
10
     * @var string
11
     */
12
    private $fieldName;
13
14
    /**
15
     * @var bool
16
     */
17
    private $required;
18
19
    /**
20
     * @var callable|null
21
     */
22
    private $condition;
23
24
    /**
25
     * @var bool
26
     */
27
    private $isArray;
28
29
    /**
30
     * @var Strategy
31
     */
32
    private $strategy;
33
34
    /**
35
     * StructureField constructor.
36
     * @param string $fieldName
37
     * @param bool $required
38
     * @param callable|null $condition
39
     * @param bool $isArray
40
     * @param Strategy $strategy
41
     */
42
    public function __construct(
43
        string $fieldName,
44
        bool $required,
45
        ?callable $condition,
46
        bool $isArray,
47
        Strategy $strategy
48
    ) {
49
        $this->fieldName = $fieldName;
50
        $this->required = $required;
51
        $this->condition = $condition;
52
        $this->isArray = $isArray;
53
        $this->strategy = $strategy;
54
    }
55
56
    /**
57
     * @inheritdoc
58
     */
59
    public function fieldName(): string
60
    {
61
        return $this->fieldName;
62
    }
63
64
    /**
65
     * @inheritdoc
66
     */
67
    public function required(): bool
68
    {
69
        return $this->required;
70
    }
71
72
    /**
73
     * @inheritdoc
74
     */
75
    public function condition(): ?callable
76
    {
77
        return $this->condition;
78
    }
79
80
    /**
81
     * @inheritdoc
82
     */
83
    public function isArray(): bool
84
    {
85
        return $this->isArray;
86
    }
87
88
    /**
89
     * @return Strategy
90
     */
91
    public function strategy(): Strategy
92
    {
93
        return $this->strategy;
94
    }
95
}
96