1 | <?php |
||
7 | final class DefinitionGroup |
||
8 | { |
||
9 | /** |
||
10 | * @var string |
||
11 | */ |
||
12 | private $namespace; |
||
13 | |||
14 | /** |
||
15 | * @var EventDefinition[] |
||
16 | */ |
||
17 | private $events = []; |
||
18 | |||
19 | /** |
||
20 | * @var array |
||
21 | */ |
||
22 | private $defaults = []; |
||
23 | |||
24 | /** |
||
25 | * @var array <type, template> |
||
26 | */ |
||
27 | private $typeSerializer = [ |
||
28 | 'string' => '({type}) {param}', |
||
29 | 'array' => '({type}) {param}', |
||
30 | 'integer' => '({type}) {param}', |
||
31 | 'int' => '({type}) {param}', |
||
32 | 'bool' => '({type}) {param}', |
||
33 | 'float' => '({type}) {param}', |
||
34 | ]; |
||
35 | |||
36 | /** |
||
37 | * @var array <type, template> |
||
38 | */ |
||
39 | private $typeDeserializer = [ |
||
40 | 'string' => '({type}) {param}', |
||
41 | 'array' => '({type}) {param}', |
||
42 | 'integer' => '({type}) {param}', |
||
43 | 'int' => '({type}) {param}', |
||
44 | 'bool' => '({type}) {param}', |
||
45 | 'float' => '({type}) {param}', |
||
46 | ]; |
||
47 | |||
48 | /** |
||
49 | * @var array <field, template> |
||
50 | */ |
||
51 | private $fieldSerializer = []; |
||
52 | |||
53 | /** |
||
54 | * @var array <field, template> |
||
55 | */ |
||
56 | private $fieldDeserializer = []; |
||
57 | |||
58 | /** |
||
59 | * @var CommandDefinition[] |
||
60 | */ |
||
61 | private $commands = []; |
||
62 | |||
63 | /** |
||
64 | * @var string[] |
||
65 | */ |
||
66 | private $typeAliases = []; |
||
67 | |||
68 | 3 | public function __construct() |
|
73 | |||
74 | 1 | public static function create(string $namespace): DefinitionGroup |
|
78 | |||
79 | 3 | public function withNamespace(string $namespace): DefinitionGroup |
|
85 | |||
86 | 3 | public function typeSerializer(string $type, string $template) |
|
92 | |||
93 | 3 | public function serializerForType($type) |
|
99 | |||
100 | 3 | public function typeDeserializer(string $type, string $template) |
|
104 | |||
105 | 3 | public function deserializerForType($type) |
|
111 | |||
112 | 2 | public function fieldSerializer(string $field, string $template) |
|
116 | |||
117 | 3 | public function serializerForField($field) |
|
121 | |||
122 | 2 | public function fieldDeserializer(string $field, string $template) |
|
126 | |||
127 | 3 | public function deserializerForField($field) |
|
131 | |||
132 | 2 | public function fieldDefault(string $name, string $type, string $example = null) |
|
137 | |||
138 | 1 | public function aliasType(string $alias, string $type) |
|
142 | |||
143 | 3 | public function resolveTypeAlias(string $alias = null) |
|
151 | |||
152 | 3 | public function event(string $name): EventDefinition |
|
156 | |||
157 | 3 | public function command(string $name) |
|
161 | |||
162 | 2 | public function typeForField(string $field): string |
|
166 | |||
167 | 2 | public function exampleForField(string $field) |
|
171 | |||
172 | /** |
||
173 | * @return EventDefinition[] |
||
174 | */ |
||
175 | 3 | public function events(): array |
|
179 | |||
180 | /** |
||
181 | * @return CommandDefinition[] |
||
182 | */ |
||
183 | 3 | public function commands(): array |
|
187 | |||
188 | 3 | public function namespace(): string |
|
192 | } |