Validation::getInvocation()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * This file is part of the Ray.ValidateModule package
4
 *
5
 * @license http://opensource.org/licenses/bsd-license.php BSD
6
 */
7
namespace Ray\Validation;
8
9
use Ray\Aop\MethodInvocation;
10
11
class Validation implements ValidationInterface
12
{
13
    /**
14
     * @var array [$name =>]
15
     */
16
    private $failure = [];
17
18
    /**
19
     * @var MethodInvocation
20
     */
21
    private $invocation;
22
23
    public function __construct(array $failure = [])
24
    {
25
        $this->failure = $failure;
26
    }
27
28
    public function setInvocation(MethodInvocation $invocation)
29
    {
30
        $this->invocation = $invocation;
31
    }
32
33
    /**
34
     * @param string $name    error target name
35
     * @param string $message message
36
     */
37
    public function addError($name, $message)
38
    {
39
        $this->failure[$name][] = $message;
40
    }
41
42
    /**
43
     * @param array $message
44
     */
45
    public function addErrors(array $message)
46
    {
47
        $this->failure = $message;
48
    }
49
50
    /**
51
     * @return array
52
     */
53
    public function getMessages()
54
    {
55
        return $this->failure;
56
    }
57
58
    /**
59
     * @return MethodInvocation
60
     */
61
    public function getInvocation()
62
    {
63
        return $this->invocation;
64
    }
65
}
66