1 | <?php declare(strict_types = 1); |
||
13 | class FunctionGenerator extends AbstractGenerator |
||
14 | { |
||
15 | /** @var string Function name */ |
||
16 | protected $name; |
||
17 | |||
18 | /** @var array Collection of function arguments */ |
||
19 | protected $arguments = []; |
||
20 | |||
21 | /** @var array Collection of function arguments descriptions */ |
||
22 | protected $argumentDescriptions = []; |
||
23 | |||
24 | /** |
||
25 | * FunctionGenerator constructor. |
||
26 | * |
||
27 | * @param GenericGenerator $parent Parent Generator |
||
28 | * @param string $name Function name |
||
29 | */ |
||
30 | public function __construct(string $name, GenericGenerator $parent = null) |
||
36 | |||
37 | /** |
||
38 | * Set function argument. |
||
39 | * |
||
40 | * @param string $name Argument name |
||
41 | * @param string|null $type Argument type |
||
42 | * @param string $description Argument description |
||
43 | * |
||
44 | * @return FunctionGenerator |
||
45 | */ |
||
46 | public function defArgument(string $name, string $type = null, string $description = null) : FunctionGenerator |
||
53 | |||
54 | /** |
||
55 | * {@inheritdoc} |
||
56 | */ |
||
57 | public function code(int $indentation = 0) : string |
||
75 | |||
76 | /** |
||
77 | * Build function definition. |
||
78 | * |
||
79 | * @return string Function definition |
||
80 | */ |
||
81 | protected function buildDefinition() |
||
85 | |||
86 | /** |
||
87 | * Build function arguments. |
||
88 | * |
||
89 | * @return string |
||
90 | */ |
||
91 | protected function buildArguments() : string |
||
101 | |||
102 | /** |
||
103 | * Add function code line. |
||
104 | * |
||
105 | * @param string $code Code line |
||
106 | * |
||
107 | * @return $this |
||
108 | */ |
||
109 | public function defLine(string $code) |
||
115 | } |
||
116 |