Completed
Push — master ( 86a533...7da8d3 )
by WEBEWEB
01:47
created

AbstractValidator::getRuleSet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of the core-library package.
5
 *
6
 * (c) 2018 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Library\Core\Validation;
13
14
use WBW\Library\Core\Validation\API\ValidationRuleSetInterface;
15
use WBW\Library\Core\Validation\API\ValidatorInterface;
16
17
/**
18
 * Abstract validator.
19
 *
20
 * @author webeweb <https://github.com/webeweb/>
21
 * @package WBW\Library\Core\Validation
22
 * @abstract
23
 */
24
abstract class AbstractValidator implements ValidatorInterface {
25
26
    /**
27
     * Rule set.
28
     *
29
     * @var ValidationRuleSetInterface
30
     */
31
    private $ruleSet;
32
33
    /**
34
     * Constructor.
35
     *
36
     * @param ValidationRuleSetInterface $ruleSet The rule set.
37
     */
38
    protected function __construct(ValidationRuleSetInterface $ruleSet) {
39
        $this->setRuleSet($ruleSet);
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function getRuleSet() {
46
        return $this->ruleSet;
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function isValid($object) {
53
        return $this->ruleSet->isValid($object);
54
    }
55
56
    /**
57
     * Set the rule set.
58
     *
59
     * @param ValidationRuleSetInterface $ruleSet The rule set.
60
     * @return ValidatorInterface Returns this validator.
61
     */
62
    protected function setRuleSet(ValidationRuleSetInterface $ruleSet) {
63
        $this->ruleSet = $ruleSet;
64
        return $this;
65
    }
66
67
}
68