1 | <?php |
||
5 | abstract class DefinitionWithFields |
||
6 | { |
||
7 | /** |
||
8 | * @var DefinitionGroup |
||
9 | */ |
||
10 | protected $group; |
||
11 | |||
12 | /** |
||
13 | * @var string |
||
14 | */ |
||
15 | protected $name; |
||
16 | |||
17 | /** |
||
18 | * @var array[] |
||
19 | */ |
||
20 | protected $fields = []; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $fieldsFrom = ''; |
||
26 | |||
27 | /** |
||
28 | * @var array <field, template> |
||
29 | */ |
||
30 | protected $fieldSerializers = []; |
||
31 | |||
32 | /** |
||
33 | * @var array <field, template> |
||
34 | */ |
||
35 | protected $fieldDeserializers = []; |
||
36 | |||
37 | 3 | public function __construct(DefinitionGroup $group, string $name) |
|
42 | |||
43 | /** |
||
44 | * @param string $otherType |
||
45 | * @return $this |
||
46 | */ |
||
47 | 2 | public function withFieldsFrom(string $otherType) |
|
53 | |||
54 | 3 | public function name(): string |
|
58 | |||
59 | 3 | public function fields(): array |
|
63 | |||
64 | 3 | public function fieldsFrom(): string |
|
68 | |||
69 | 3 | public function field(string $name, string $type = null, string $example = null) |
|
78 | |||
79 | 2 | public function fieldSerializer($field, $template) |
|
85 | |||
86 | 3 | public function serializerForField($field) |
|
90 | |||
91 | 2 | public function fieldDeserializer($field, $template) |
|
97 | |||
98 | 3 | public function deserializerForField($field) |
|
102 | |||
103 | 3 | public function deserializerForType($type) |
|
107 | |||
108 | 3 | public function serializerForType($type) |
|
112 | } |