Completed
Push — master ( 306e90...0ddde3 )
by Maxim
02:42
created

BooleanNode::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 3
1
<?php
2
3
namespace Weew\ConfigSchema\Nodes;
4
5
use Weew\ConfigSchema\IConfigSchema;
6
use Weew\Validator\Constraints\BooleanConstraint;
7
use Weew\Validator\Constraints\NotNullConstraint;
8
use Weew\Validator\Constraints\NullableConstraint;
9
10
class BooleanNode extends Node implements IBooleanNode {
11
    /**
12
     * BooleanNode constructor.
13
     *
14
     * @param IConfigSchema $schema
15
     * @param string $key
16
     * @param string $message
17
     */
18
    public function __construct(IConfigSchema $schema, $key, $message = null) {
19
        parent::__construct($schema, $key);
20
21
        $this->constraints([
22
            new NotNullConstraint($message),
23
            new BooleanConstraint(),
24
        ]);
25
    }
26
27
    /**
28
     * @return IBooleanNode
29
     */
30
    public function nullable() {
31
        return $this->constraint(
32
            new NullableConstraint()
33
        );
34
    }
35
}
36
37