1 | <?php |
||
16 | class RdataHandlers |
||
17 | { |
||
18 | private static $handlers = [ |
||
19 | Rdata\LOC::TYPE => __CLASS__.'::handleLocRdata', |
||
20 | Rdata\TXT::TYPE => __CLASS__.'::handleTxtRdata', |
||
21 | Rdata\APL::TYPE => __CLASS__.'::handleAplRdata', |
||
22 | ]; |
||
23 | |||
24 | 7 | public static function getHandlers(): array |
|
28 | |||
29 | /** |
||
30 | * Transform a DMS string to a decimal representation. Used for LOC records. |
||
31 | * |
||
32 | * @param int $deg Degrees |
||
33 | * @param int $min Minutes |
||
34 | * @param float $sec Seconds |
||
35 | * @param string $hemisphere Either 'N', 'S', 'E', or 'W' |
||
36 | * |
||
37 | * @return float |
||
38 | */ |
||
39 | 1 | public static function dmsToDecimal(int $deg, int $min, float $sec, string $hemisphere): float |
|
45 | |||
46 | /** |
||
47 | * @param \ArrayIterator $iterator |
||
48 | * |
||
49 | * @return Rdata\LOC |
||
50 | */ |
||
51 | 1 | public static function handleLocRdata(\ArrayIterator $iterator): Rdata\LOC |
|
65 | |||
66 | /** |
||
67 | * @param \ArrayIterator $iterator |
||
68 | * |
||
69 | * @return Rdata\APL |
||
70 | * |
||
71 | * @throws ParseException |
||
72 | */ |
||
73 | 4 | public static function handleAplRdata(\ArrayIterator $iterator): Rdata\APL |
|
90 | |||
91 | /** |
||
92 | * @param \ArrayIterator $iterator |
||
93 | * |
||
94 | * @return Rdata\TXT |
||
95 | */ |
||
96 | 3 | public static function handleTxtRdata(\ArrayIterator $iterator): Rdata\TXT |
|
108 | |||
109 | /** |
||
110 | * Returns RData instances for types that do not have explicitly declared handler methods. |
||
111 | * |
||
112 | * @param string $type |
||
113 | * @param \ArrayIterator $iterator |
||
114 | * @return Rdata\RdataInterface |
||
115 | */ |
||
116 | 5 | public static function catchAll(string $type, \ArrayIterator $iterator): Rdata\RdataInterface |
|
124 | |||
125 | /** |
||
126 | * @param StringIterator $string |
||
127 | * @param StringIterator $txt |
||
128 | */ |
||
129 | 3 | private static function handleTxt(StringIterator $string, StringIterator $txt): void |
|
146 | |||
147 | /** |
||
148 | * Return current entry and moves the iterator to the next entry. |
||
149 | * |
||
150 | * @param \ArrayIterator $iterator |
||
151 | * |
||
152 | * @return string |
||
153 | */ |
||
154 | 1 | private static function pop(\ArrayIterator $iterator): string |
|
161 | |||
162 | /** |
||
163 | * Get all the remaining values of an iterator as an array. |
||
164 | * |
||
165 | * @param \ArrayIterator $iterator |
||
166 | * |
||
167 | * @return array |
||
168 | */ |
||
169 | 5 | private static function getAllRemaining(\ArrayIterator $iterator): array |
|
179 | } |
||
180 |