Completed
Push — master ( c90891...1c767a )
by Maxim
04:17
created

Node::assert()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Weew\ConfigSchema\Nodes;
4
5
use Weew\ConfigSchema\IConfigSchema;
6
use Weew\Validator\IConstraint;
7
use Weew\Validator\IValidationResult;
8
9
class Node implements INode {
10
    /**
11
     * @var IConfigSchema
12
     */
13
    protected $schema;
14
15
    /**
16
     * @var string
17
     */
18
    protected $key;
19
20
    /**
21
     * Node constructor.
22
     *
23
     * @param IConfigSchema $schema
24
     * @param string $key
25
     */
26
    public function __construct(IConfigSchema $schema, $key) {
27
        $this->key = $key;
28
        $this->schema = $schema;
29
    }
30
31
    /**
32
     * @param string $key
33
     * @param string $message
34
     *
35
     * @return IValueNode
36
     */
37
    public function hasValue($key, $message = null) {
38
        return $this->schema->hasValue($key, $message);
39
    }
40
41
    /**
42
     * @param string $key
43
     * @param string $message
44
     *
45
     * @return IStringNode
46
     */
47
    public function hasString($key, $message = null) {
48
        return $this->schema->hasString($key, $message);
49
    }
50
51
    /**
52
     * @param string $key
53
     * @param string $message
54
     *
55
     * @return INumericNode
56
     */
57
    public function hasNumber($key, $message = null) {
58
        return $this->schema->hasNumber($key, $message);
59
    }
60
61
    /**
62
     * @param string $key
63
     * @param string $message
64
     *
65
     * @return IBooleanNode
66
     */
67
    public function hasBoolean($key, $message = null) {
68
        return $this->schema->hasBoolean($key, $message);
69
    }
70
71
    /**
72
     * @param string $key
73
     * @param string $message
74
     *
75
     * @return IArrayNode
76
     */
77
    public function hasArray($key, $message = null) {
78
        return $this->schema->hasArray($key, $message);
79
    }
80
81
    /**
82
     * @param string $key
83
     * @param string $message
84
     *
85
     * @return IStringNode
86
     */
87
    public function hasArrayKeys($key, $message = null) {
88
        return $this->schema->hasArrayKeys($key, $message);
89
    }
90
91
    /**
92
     * @param string $key
93
     * @param string $message
94
     *
95
     * @return IStringNode
96
     */
97
    public function hasArrayValues($key, $message = null) {
98
        return $this->schema->hasArrayValues($key, $message);
99
    }
100
101
    /**
102
     * @return null
103
     */
104
    public function assert() {
105
        return $this->schema->assert();
106
    }
107
108
    /**
109
     * @return IValidationResult
110
     */
111
    public function check() {
112
        return $this->schema->check();
113
    }
114
115
    /**
116
     * @param IConstraint $constraint
117
     *
118
     * @return $this
119
     */
120
    public function constraint(IConstraint $constraint) {
121
        $this->schema->constraint($this->key, $constraint);
122
123
        return $this;
124
    }
125
126
    /**
127
     * @param IConstraint[] $constraints
128
     *
129
     * @return $this
130
     */
131
    public function constraints(array $constraints) {
132
        $this->schema->constraints($this->key, $constraints);
133
134
        return $this;
135
    }
136
}
137