Completed
Push — master ( d1c976...1cf840 )
by Hannes
02:12
created

Exception::pushValidatorName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
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 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace hanneskod\clean;
4
5
/**
6
 * Thrown when validation fails
7
 */
8
class Exception extends \Exception
9
{
10
    /**
11
     * @var string[] Name(s) of failing validator(s)
12
     */
13
    private $validatorNames = [];
14
15
    /**
16
     * Push name of failing validator
17
     *
18
     * @param  string $name
19
     * @return void
20
     */
21
    public function pushValidatorName($name)
22
    {
23
        $this->validatorNames[] = $name;
24
    }
25
26
    /**
27
     * Get name of failing validator
28
     *
29
     * @return string
30
     */
31
    public function getSourceValidatorName()
32
    {
33
        return implode(array_reverse($this->validatorNames), '::');
34
    }
35
}
36