1 | <?php |
||
15 | class GeneralParser extends BaseParser |
||
16 | { |
||
17 | const ATTR_AGE = 'age'; |
||
18 | const ATTR_NAME = 'na'; |
||
19 | const ATTR_NAME_VERSION_1 = 'na1'; |
||
20 | const ATTR_BLOCK = 'blk'; |
||
21 | const ATTR_GENERAL_CATEGORY = 'gc'; |
||
22 | const ATTR_SCRIPT = 'sc'; |
||
23 | |||
24 | /** |
||
25 | * @return General |
||
26 | */ |
||
27 | protected function parse() |
||
28 | { |
||
29 | $names = $this->parseNames(); |
||
30 | $block = $this->parseBlock(); |
||
31 | $age = $this->parseAge(); |
||
32 | $generalCategory = $this->parseGeneralCategory(); |
||
33 | $script = $this->parseScript(); |
||
34 | |||
35 | return new General($names, $block, $age, $generalCategory, $script); |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * @return Names |
||
40 | */ |
||
41 | private function parseNames() |
||
42 | { |
||
43 | $primaryName = $this->parsePrimaryName(); |
||
44 | $version1Name = $this->parseVersion1Name(); |
||
45 | |||
46 | return new Names($primaryName, [], $version1Name); |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * @return Name |
||
51 | */ |
||
52 | private function parsePrimaryName() |
||
53 | { |
||
54 | return $this->parseNameWithValue( |
||
55 | $this->getOptionalAttribute(self::ATTR_NAME) |
||
56 | ); |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * @return Name |
||
61 | */ |
||
62 | private function parseVersion1Name() |
||
63 | { |
||
64 | return $this->parseNameWithValue( |
||
65 | $this->getOptionalAttribute(self::ATTR_NAME_VERSION_1) |
||
66 | ); |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * @param $value |
||
71 | * @return Assigned|Unassigned |
||
72 | */ |
||
73 | private function parseNameWithValue($value) |
||
83 | |||
84 | /** |
||
85 | * @return Block |
||
86 | */ |
||
87 | private function parseBlock() |
||
91 | |||
92 | /** |
||
93 | * @return Version |
||
94 | */ |
||
95 | private function parseAge() |
||
99 | |||
100 | /** |
||
101 | * @return GeneralCategory |
||
102 | */ |
||
103 | private function parseGeneralCategory() |
||
107 | |||
108 | /** |
||
109 | * @return Script |
||
110 | */ |
||
111 | private function parseScript() |
||
115 | } |