Subject   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 67
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A addRule() 0 4 1
A getKey() 0 4 1
A getName() 0 4 1
A getRules() 0 4 1
1
<?php
2
/**
3
 * Particle.
4
 *
5
 * @link      http://github.com/particle-php for the canonical source repository
6
 * @copyright Copyright (c) 2005-2016 Particle (http://particle-php.com)
7
 * @license   https://github.com/particle-php/validator/blob/master/LICENSE New BSD License
8
 */
9
namespace Particle\Validator\Output;
10
11
/**
12
 * Subject is an object for communicating the internal state of a Chain to an output object.
13
 *
14
 * @package Particle\Validator\Output
15
 */
16
class Subject
17
{
18
    /**
19
     * @var string
20
     */
21
    protected $key;
22
23
    /**
24
     * @var string
25
     */
26
    protected $name;
27
28
    /**
29
     * @var Rule[]
30
     */
31
    protected $rules;
32
33
    /**
34
     * @param string $key
35
     * @param string $name
36
     */
37 2
    public function __construct($key, $name)
38
    {
39 2
        $this->key = $key;
40 2
        $this->name = $name;
41 2
    }
42
43
    /**
44
     * Adds a rule for this subject.
45
     *
46
     * @param Rule $rule
47
     */
48 2
    public function addRule(Rule $rule)
49
    {
50 2
        $this->rules[] = $rule;
51 2
    }
52
53
    /**
54
     * Returns the key for this subject.
55
     *
56
     * @return string
57
     */
58 2
    public function getKey()
59
    {
60 2
        return $this->key;
61
    }
62
63
    /**
64
     * Returns the name for this subject.
65
     *
66
     * @return string
67
     */
68 2
    public function getName()
69
    {
70 2
        return $this->name;
71
    }
72
73
    /**
74
     * Returns an array of all rules in this subject.
75
     *
76
     * @return Rule[]
77
     */
78 2
    public function getRules()
79
    {
80 2
        return $this->rules;
81
    }
82
}
83