ObjectAttribute::hasInterface()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 0
loc 6
rs 9.4286
c 1
b 1
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
/**
3
 * Author: Nil Portugués Calderó <[email protected]>
4
 * Date: 9/16/14
5
 * Time: 9:18 PM
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace NilPortugues\Validator\Attribute\Object;
12
13
use NilPortugues\Validator\Attribute\GenericAttribute;
14
use NilPortugues\Validator\Validator;
15
16
/**
17
 * Class ObjectAttribute
18
 * @package NilPortugues\Validator\Attribute\ObjectAttribute
19
 */
20
class ObjectAttribute extends GenericAttribute
21
{
22
    /**
23
     * @param string    $propertyName
24
     * @param Validator $validator
25
     * @param array     $errorMessages
26
     * @param array     $functionMap
27
     */
28
    public function __construct($propertyName, Validator $validator, array &$errorMessages, array &$functionMap)
29
    {
30
        parent::__construct($propertyName, $validator, $errorMessages, $functionMap);
31
32
        $this->addCondition(__METHOD__);
33
    }
34
35
    /**
36
     * @param string $instanceOf
37
     *
38
     * @return $this
39
     */
40
    public function isInstanceOf($instanceOf)
41
    {
42
        $this->addCondition(__METHOD__, [$instanceOf]);
43
44
        return $this;
45
    }
46
47
    /**
48
     * @param string $property
49
     *
50
     * @return $this
51
     */
52
    public function hasProperty($property)
53
    {
54
        $this->addCondition(__METHOD__, [$property]);
55
56
        return $this;
57
    }
58
59
    /**
60
     * @param string $method
61
     *
62
     * @return $this
63
     */
64
    public function hasMethod($method)
65
    {
66
        $this->addCondition(__METHOD__, [$method]);
67
68
        return $this;
69
    }
70
71
    /**
72
     * @return $this
73
     */
74
    public function hasParentClass()
75
    {
76
        $this->addCondition(__METHOD__);
77
78
        return $this;
79
    }
80
81
    /**
82
     * @param string $parentClass
83
     *
84
     * @return $this
85
     */
86
    public function isChildOf($parentClass)
87
    {
88
        $this->addCondition(__METHOD__, [$parentClass]);
89
90
        return $this;
91
    }
92
93
    /**
94
     * @param string $inheritsClass
95
     *
96
     * @return $this
97
     */
98
    public function inheritsFrom($inheritsClass)
99
    {
100
        $this->addCondition(__METHOD__, [$inheritsClass]);
101
102
        return $this;
103
    }
104
105
    /**
106
     * @param string $interface
107
     *
108
     * @return $this
109
     */
110
    public function hasInterface($interface)
111
    {
112
        $this->addCondition(__METHOD__, [$interface]);
113
114
        return $this;
115
    }
116
}
117