ValidatorAwareTrait::setValidator()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php
2
3
namespace Kontrolio;
4
5
/**
6
 * Trait to provide validation service.
7
 *
8
 * @package Kontrolio
9
 */
10
trait ValidatorAwareTrait
11
{
12
    /**
13
     * Validator instance.
14
     *
15
     * @var ValidatorInterface
16
     */
17
    protected $validator;
18
19
    /**
20
     * Sets validator.
21
     *
22
     * @param ValidatorInterface $validator
23
     *
24
     * @return $this
25
     */
26
    public function setValidator(ValidatorInterface $validator)
27
    {
28
        $this->validator = $validator;
29
30
        return $this;
31
    }
32
33
    /**
34
     * Performs validation.
35
     *
36
     * @return bool
37
     */
38
    public function validate()
39
    {
40
        return $this->validator->validate();
41
    }
42
}
43