1 | <?php declare(strict_types = 1); |
||
13 | class ClassGenerator extends AbstractGenerator |
||
14 | { |
||
15 | /** OOP public visibility */ |
||
16 | const VISIBILITY_PUBLIC = 'public'; |
||
17 | |||
18 | /** OOP protected visibility */ |
||
19 | const VISIBILITY_PROTECTED = 'protected'; |
||
20 | |||
21 | /** OOP private visibility */ |
||
22 | const VISIBILITY_PRIVATE = 'private'; |
||
23 | |||
24 | /** @var string Class name */ |
||
25 | protected $className; |
||
26 | |||
27 | /** @var string Class namespace */ |
||
28 | protected $namespace; |
||
29 | |||
30 | /** @var array Collection of class uses */ |
||
31 | protected $uses = []; |
||
32 | |||
33 | /** @var string Multiline file description */ |
||
34 | protected $fileDescription; |
||
35 | |||
36 | /** @var array Class constants */ |
||
37 | protected $constants; |
||
38 | |||
39 | /** @var array Class static properties */ |
||
40 | protected $staticProperties; |
||
41 | |||
42 | /** @var array Class static methods */ |
||
43 | protected $staticMethods; |
||
44 | |||
45 | /** @var array Class properties */ |
||
46 | protected $properties; |
||
47 | |||
48 | /** @var array Class methods */ |
||
49 | protected $methods; |
||
50 | |||
51 | /** @var bool Flag that class is abstract */ |
||
52 | protected $isAbstract; |
||
53 | |||
54 | /** @var bool Flag that class is final */ |
||
55 | protected $isFinal; |
||
56 | |||
57 | /** |
||
58 | * ClassGenerator constructor. |
||
59 | * |
||
60 | * @param string $className Class name |
||
61 | * @param GenericGenerator $parent Parent generator |
||
62 | */ |
||
63 | public function __construct(string $className, GenericGenerator $parent = null) |
||
69 | |||
70 | /** |
||
71 | * Set class to be final. |
||
72 | * |
||
73 | * @return ClassGenerator |
||
74 | */ |
||
75 | public function defFinal() : ClassGenerator |
||
85 | |||
86 | /** |
||
87 | * Set class to be abstract. |
||
88 | * |
||
89 | * @return ClassGenerator |
||
90 | */ |
||
91 | public function defAbstract() : ClassGenerator |
||
101 | |||
102 | /** |
||
103 | * Set class file description. |
||
104 | * |
||
105 | * @param array $description Collection of class file description lines |
||
106 | * |
||
107 | * @return ClassGenerator |
||
108 | */ |
||
109 | public function defDescription(array $description) : ClassGenerator |
||
120 | |||
121 | /** |
||
122 | * Set class namespace. |
||
123 | * |
||
124 | * @param string $namespace |
||
125 | * |
||
126 | * @return ClassGenerator |
||
127 | */ |
||
128 | public function defNamespace(string $namespace) : ClassGenerator |
||
134 | |||
135 | /** |
||
136 | * Set class use. |
||
137 | * |
||
138 | * @param string $use |
||
139 | * |
||
140 | * @return ClassGenerator |
||
141 | */ |
||
142 | public function defUse(string $use) : ClassGenerator |
||
148 | |||
149 | /** |
||
150 | * Set protected class property. |
||
151 | * |
||
152 | * @param string $name Property name |
||
153 | * @param mixed $value Property value |
||
154 | * |
||
155 | * @return PropertyGenerator |
||
156 | */ |
||
157 | public function defProtectedProperty(string $name, $value) : PropertyGenerator |
||
161 | |||
162 | /** |
||
163 | * Set class property. |
||
164 | * |
||
165 | * @param string $name Property name |
||
166 | * @param mixed $value Property value |
||
167 | * |
||
168 | * @return PropertyGenerator |
||
169 | */ |
||
170 | public function defProperty(string $name, $value) : PropertyGenerator |
||
174 | |||
175 | /** |
||
176 | * Set protected static class property. |
||
177 | * |
||
178 | * @param string $name Property name |
||
179 | * @param mixed $value Property value |
||
180 | * |
||
181 | * @return PropertyGenerator |
||
182 | */ |
||
183 | public function defProtectedStaticProperty(string $name, $value) : PropertyGenerator |
||
187 | |||
188 | /** |
||
189 | * Set static class property. |
||
190 | * |
||
191 | * @param string $name Property name |
||
192 | * @param mixed $value Property value |
||
193 | * |
||
194 | * @return PropertyGenerator |
||
195 | */ |
||
196 | public function defStaticProperty(string $name, $value) : PropertyGenerator |
||
200 | |||
201 | /** |
||
202 | * {@inheritdoc} |
||
203 | * @throws \InvalidArgumentException |
||
204 | */ |
||
205 | public function code(int $indentation = 0) : string |
||
251 | |||
252 | /** |
||
253 | * Build function definition. |
||
254 | * |
||
255 | * @return string Function definition |
||
256 | */ |
||
257 | protected function buildDefinition() |
||
264 | } |
||
265 |