Passed
Push — master ( f4595b...225dc0 )
by Maxim
03:36 queued 37s
created

PropertyData::getOutputHandlers()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is a part of "Axessors" library.
4
 *
5
 * @author <[email protected]>
6
 * @license GPL
7
 */
8
9
namespace NoOne4rever\Axessors;
10
11
/**
12
 * Class PropertyData.
13
 *
14
 * Stores information about Axessors property.
15
 *
16
 * @package NoOne4rever\Axessors
17
 */
18
class PropertyData
19
{
20
    /** @var \ReflectionProperty property's reflection */
21
    public $reflection;
22
23
    /** @var string[] access modifiers for getter and setter */
24
    private $accessibility;
25
    /** @var string an alias of property name */
26
    private $alias;
27
    /** @var array type tree */
28
    private $type;
29
    /** @var string[] conditions for setter */
30
    private $conditionsIn = [];
31
    /** @var string[] conditions for getter */
32
    private $conditionsOut = [];
33
    /** @var string[] handlers for setter */
34
    private $handlersIn = [];
35
    /** @var string[] handlers for getter */
36
    private $handlersOut = [];
37
    /** @var string[] methods' names */
38
    private $methods = [];
39
40
    /**
41
     * PropertyData constructor.
42
     *
43
     * @param \ReflectionProperty $reflection property's information
44
     * @param array $tokens tokens form Axessors comment
45
     */
46
    public function __construct(\ReflectionProperty $reflection, array $tokens)
47
    {
48
        $parser = new Parser($reflection, $tokens);
49
        $this->reflection = $reflection;
50
51
        $this->accessibility = $parser->processAccessModifier();
52
        $this->alias = $parser->getAlias();
53
54
        $typeProcessor = new TypeProcessor($parser->getReflection(), $parser->getNamespace(), $parser->getTypeDef());
55
        $this->type = $typeProcessor->processType();
56
        
57
        $conditionsProcessor = new ConditionsProcessor($parser->getInConditions(), $parser->getOutConditions(),
58
            $parser->getNamespace());
59
        $this->conditionsIn = $conditionsProcessor->processInputConditions();
60
        $this->conditionsOut = $conditionsProcessor->processOutputConditions();
61
        
62
        $handlersProcessor = new HandlersProcessor($parser->getInHandlers(), $parser->getOutHandlers(),
63
            $parser->getNamespace());
64
        $this->handlersIn = $handlersProcessor->processInputHandlers();
65
        $this->handlersOut = $handlersProcessor->processOutputHandlers();
66
        
67
        
68
        $methodsProcessor = new MethodsProcessor($this->accessibility['write'] ?? '',
69
            $this->accessibility['read'] ?? '', $this->getAlias());
70
        $this->methods = $methodsProcessor->processMethods($typeProcessor->getTypeTree());
71
    }
72
73
    /**
74
     * Getter for {@see PropertyData::$accessibility}.
75
     *
76
     * @return string[] {@see PropertyData::$accessibility}
77
     */
78
    public function getAccessibility(): array
79
    {
80
        return $this->accessibility;
81
    }
82
83
    /**
84
     * Getter for {@see PropertyData::$alias}.
85
     *
86
     * @return string {@see PropertyData::$alias}
87
     */
88
    public function getAlias(): string
89
    {
90
        return $this->alias;
91
    }
92
93
    /**
94
     * Getter for {@see PropertyData::$methods}.
95
     *
96
     * @return string[] {@see PropertyData::$methods}
97
     */
98
    public function getMethods(): array
99
    {
100
        return $this->methods;
101
    }
102
103
    /**
104
     * Getter for {@see PropertyData::$conditionsIn}.
105
     *
106
     * @return string[] {@see PropertyData::$conditionsIn}
107
     */
108
    public function getInputConditions(): array
109
    {
110
        return $this->conditionsIn;
111
    }
112
113
    /**
114
     * Getter for {@see PropertyData::$conditionsOut}.
115
     *
116
     * @return string[] {@see PropertyData::$conditionsOut}
117
     */
118
    public function getOutputConditions(): array
119
    {
120
        return $this->conditionsOut;
121
    }
122
123
    /**
124
     * Getter for {@see PropertyData::$handlersOut}.
125
     *
126
     * @return string[] {@see PropertyData::$handlersOut}
127
     */
128
    public function getOutputHandlers(): array
129
    {
130
        return $this->handlersOut;
131
    }
132
133
    /**
134
     * Getter for {@see PropertyData::$handlersIn}.
135
     *
136
     * @return string[] {@see PropertyData::$handlersIn}
137
     */
138
    public function getInputHandlers(): array
139
    {
140
        return $this->handlersIn;
141
    }
142
143
    /**
144
     * Getter for {@see PropertyData::$type}.
145
     *
146
     * @return array {@see PropertyData::$type}
147
     */
148
    public function getTypeTree(): array
149
    {
150
        return $this->type;
151
    }
152
153
    /**
154
     * Getter for {@see PropertyData::$alias}.
155
     *
156
     * @return string {@see PropertyData::$alias}
157
     */
158
    public function getName(): string
159
    {
160
        return $this->alias;
161
    }
162
}
163