@@ -53,8 +53,7 @@ discard block |
||
| 53 | 53 | * @param bool $isFirst |
| 54 | 54 | * @param string $previousName |
| 55 | 55 | */ |
| 56 | - public function __construct |
|
| 57 | - ( |
|
| 56 | + public function __construct( |
|
| 58 | 57 | StringStream $stream, |
| 59 | 58 | string $globalOrigin = NULL, |
| 60 | 59 | string $globalTtl = NULL, |
@@ -112,8 +111,8 @@ discard block |
||
| 112 | 111 | $this->stream->ignoreHorizontalSpace(); |
| 113 | 112 | $this->extractRData(); |
| 114 | 113 | |
| 115 | - if($this->globalOrigin && substr($this->tokens['NAME'], -1) !== '.' && $this->tokens['NAME'] !== '@') { |
|
| 116 | - if($this->globalOrigin === '.') { |
|
| 114 | + if ($this->globalOrigin && substr($this->tokens['NAME'], -1) !== '.' && $this->tokens['NAME'] !== '@') { |
|
| 115 | + if ($this->globalOrigin === '.') { |
|
| 117 | 116 | $this->tokens['NAME'] .= $this->globalOrigin; |
| 118 | 117 | } else { |
| 119 | 118 | $this->tokens['NAME'] .= '.'.$this->globalOrigin; |
@@ -179,33 +178,33 @@ discard block |
||
| 179 | 178 | throw new SyntaxErrorException($this->stream); |
| 180 | 179 | } |
| 181 | 180 | } else { |
| 182 | - if($this->isFirst) { |
|
| 181 | + if ($this->isFirst) { |
|
| 183 | 182 | throw new SyntaxErrorException($this->stream); |
| 184 | 183 | } else { |
| 185 | - if(RData::isKnownType($this->tokens["NAME"]) && ! RData::isKnownType($this->tokens["TTL"])) { |
|
| 184 | + if (RData::isKnownType($this->tokens["NAME"]) && !RData::isKnownType($this->tokens["TTL"])) { |
|
| 186 | 185 | // no ttl and no origin in record, and in TTL Rdata |
| 187 | 186 | last_chance: |
| 188 | - if($this->previousName && $this->globalTtl) { |
|
| 187 | + if ($this->previousName && $this->globalTtl) { |
|
| 189 | 188 | $this->tokens['TYPE'] = $this->tokens["NAME"]; |
| 190 | 189 | $this->tokens["NAME"] = $this->previousName; |
| 191 | 190 | $this->tokens["TTL"] = $this->globalTtl; |
| 192 | 191 | } else { |
| 193 | 192 | throw new SyntaxErrorException($this->stream); |
| 194 | 193 | } |
| 195 | - } elseif(!RData::isKnownType($this->tokens["NAME"]) && RData::isKnownType($this->tokens["TTL"])) { |
|
| 194 | + } elseif (!RData::isKnownType($this->tokens["NAME"]) && RData::isKnownType($this->tokens["TTL"])) { |
|
| 196 | 195 | $this->tokens['TYPE'] = $this->tokens["TTL"]; |
| 197 | - if($this->previousName && ! $this->globalTtl) { |
|
| 198 | - $this->tokens["TTL"] = $this->tokens["NAME"]; |
|
| 196 | + if ($this->previousName && !$this->globalTtl) { |
|
| 197 | + $this->tokens["TTL"] = $this->tokens["NAME"]; |
|
| 199 | 198 | $this->tokens["NAME"] = $this->previousName; |
| 200 | - } elseif(! $this->previousName && $this->globalTtl) { |
|
| 201 | - $this->tokens["TTL"] = $this->globalTtl; |
|
| 202 | - } elseif($this->previousName && $this->globalTtl) { |
|
| 199 | + } elseif (!$this->previousName && $this->globalTtl) { |
|
| 200 | + $this->tokens["TTL"] = $this->globalTtl; |
|
| 201 | + } elseif ($this->previousName && $this->globalTtl) { |
|
| 203 | 202 | $this->tokens["TTL"] = $this->globalTtl; |
| 204 | 203 | } else { |
| 205 | 204 | throw new SyntaxErrorException($this->stream); |
| 206 | 205 | } |
| 207 | 206 | |
| 208 | - } elseif(RData::isKnownType($this->tokens["NAME"]) && RData::isKnownType($this->tokens["TTL"])) { |
|
| 207 | + } elseif (RData::isKnownType($this->tokens["NAME"]) && RData::isKnownType($this->tokens["TTL"])) { |
|
| 209 | 208 | goto last_chance; |
| 210 | 209 | } else { |
| 211 | 210 | throw new SyntaxErrorException($this->stream); |
@@ -214,12 +213,12 @@ discard block |
||
| 214 | 213 | do { |
| 215 | 214 | $char = $this->stream->currentAscii(); |
| 216 | 215 | $this->stream->previous(); |
| 217 | - } while($char->isWhiteSpace()); |
|
| 216 | + } while ($char->isWhiteSpace()); |
|
| 218 | 217 | |
| 219 | 218 | do { |
| 220 | 219 | $char = $this->stream->currentAscii(); |
| 221 | 220 | $this->stream->previous(); |
| 222 | - } while($char->isPrintableChar() && ! $char->isHorizontalSpace()); |
|
| 221 | + } while ($char->isPrintableChar() && !$char->isHorizontalSpace()); |
|
| 223 | 222 | } |
| 224 | 223 | } |
| 225 | 224 | } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | public function __construct(StringStream $stream, string $type) |
| 89 | 89 | { |
| 90 | - if (! self::isKnownType($type)) { |
|
| 90 | + if (!self::isKnownType($type)) { |
|
| 91 | 91 | throw new SyntaxErrorException($stream); |
| 92 | 92 | } |
| 93 | 93 | |
@@ -133,27 +133,27 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | $ord = $this->stream->ord(); |
| 135 | 135 | |
| 136 | - if($ord == AsciiChar::NULL) { |
|
| 136 | + if ($ord == AsciiChar::NULL) { |
|
| 137 | 137 | return; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - if($ord === AsciiChar::OPEN_BRACKET && !$this->commentOpen) { |
|
| 140 | + if ($ord === AsciiChar::OPEN_BRACKET && !$this->commentOpen) { |
|
| 141 | 141 | $this->multiLineOpened = true; |
| 142 | 142 | $this->stream->next(); |
| 143 | 143 | goto start; |
| 144 | - } elseif($this->multiLineOpened && !$this->commentOpen && $ord === AsciiChar::CLOSE_BRACKET) { |
|
| 144 | + } elseif ($this->multiLineOpened && !$this->commentOpen && $ord === AsciiChar::CLOSE_BRACKET) { |
|
| 145 | 145 | $this->multiLineOpened = false; |
| 146 | 146 | $this->stream->next(); |
| 147 | 147 | goto start; |
| 148 | - } elseif($this->multiLineOpened && !$this->commentOpen && $ord === AsciiChar::LINE_FEED) { |
|
| 148 | + } elseif ($this->multiLineOpened && !$this->commentOpen && $ord === AsciiChar::LINE_FEED) { |
|
| 149 | 149 | $this->stream->next(); |
| 150 | 150 | goto start; |
| 151 | - } elseif($ord === AsciiChar::LINE_FEED && !$this->commentOpen) { |
|
| 151 | + } elseif ($ord === AsciiChar::LINE_FEED && !$this->commentOpen) { |
|
| 152 | 152 | return; |
| 153 | 153 | } else { |
| 154 | - if($ord === AsciiChar::SEMICOLON) { |
|
| 154 | + if ($ord === AsciiChar::SEMICOLON) { |
|
| 155 | 155 | $this->stream->previous(); |
| 156 | - if($this->stream->currentAscii()->isHorizontalSpace()) { |
|
| 156 | + if ($this->stream->currentAscii()->isHorizontalSpace()) { |
|
| 157 | 157 | |
| 158 | 158 | $this->commentOpen = true; |
| 159 | 159 | $this->stream->next(); |
@@ -164,19 +164,19 @@ discard block |
||
| 164 | 164 | $this->stream->next(); |
| 165 | 165 | } |
| 166 | 166 | goto start; |
| 167 | - } elseif(($ord === AsciiChar::LINE_FEED || $ord === AsciiChar::NULL) && $this->commentOpen) { |
|
| 167 | + } elseif (($ord === AsciiChar::LINE_FEED || $ord === AsciiChar::NULL) && $this->commentOpen) { |
|
| 168 | 168 | $this->stream->next(); |
| 169 | 169 | $this->commentOpen = false; |
| 170 | 170 | goto start; |
| 171 | - } elseif($this->commentOpen) { |
|
| 171 | + } elseif ($this->commentOpen) { |
|
| 172 | 172 | $this->commentOpen = true; |
| 173 | 173 | $this->stream->next(); |
| 174 | 174 | goto start; |
| 175 | - } elseif(!$this->commentOpen) { |
|
| 176 | - if($ord === AsciiChar::SPACE && $this->tokens[$tokenName] === "") { |
|
| 175 | + } elseif (!$this->commentOpen) { |
|
| 176 | + if ($ord === AsciiChar::SPACE && $this->tokens[$tokenName] === "") { |
|
| 177 | 177 | $this->stream->next(); |
| 178 | 178 | goto start; |
| 179 | - } elseif($ord === AsciiChar::SPACE) { |
|
| 179 | + } elseif ($ord === AsciiChar::SPACE) { |
|
| 180 | 180 | return; |
| 181 | 181 | } else { |
| 182 | 182 | $this->tokens[$tokenName] .= $this->stream->current(); |
@@ -191,15 +191,15 @@ discard block |
||
| 191 | 191 | { |
| 192 | 192 | start: |
| 193 | 193 | $ord = $this->stream->ord(); |
| 194 | - if($ord == AsciiChar::NULL) { |
|
| 194 | + if ($ord == AsciiChar::NULL) { |
|
| 195 | 195 | return; |
| 196 | 196 | } |
| 197 | - if($ord === AsciiChar::SEMICOLON) { |
|
| 197 | + if ($ord === AsciiChar::SEMICOLON) { |
|
| 198 | 198 | $this->stream->next(); |
| 199 | 199 | $this->commentOpen = true; |
| 200 | 200 | goto start; |
| 201 | - } elseif($this->commentOpen) { |
|
| 202 | - if($ord === AsciiChar::NULL() || $ord === AsciiChar::LINE_FEED) { |
|
| 201 | + } elseif ($this->commentOpen) { |
|
| 202 | + if ($ord === AsciiChar::NULL() || $ord === AsciiChar::LINE_FEED) { |
|
| 203 | 203 | $this->commentOpen = false; |
| 204 | 204 | goto start; |
| 205 | 205 | } else { |
@@ -207,14 +207,14 @@ discard block |
||
| 207 | 207 | $this->commentOpen = true; |
| 208 | 208 | goto start; |
| 209 | 209 | } |
| 210 | - } elseif(!$this->commentOpen) { |
|
| 211 | - if($this->multiLineOpened) { |
|
| 212 | - if($ord === AsciiChar::CLOSE_BRACKET) { |
|
| 210 | + } elseif (!$this->commentOpen) { |
|
| 211 | + if ($this->multiLineOpened) { |
|
| 212 | + if ($ord === AsciiChar::CLOSE_BRACKET) { |
|
| 213 | 213 | $this->multiLineOpened = false; |
| 214 | 214 | } |
| 215 | 215 | $this->stream->next(); |
| 216 | 216 | goto start; |
| 217 | - } elseif($ord === AsciiChar::NULL() || $ord === AsciiChar::LINE_FEED) { |
|
| 217 | + } elseif ($ord === AsciiChar::NULL() || $ord === AsciiChar::LINE_FEED) { |
|
| 218 | 218 | return; |
| 219 | 219 | } |
| 220 | 220 | } |
@@ -233,53 +233,53 @@ discard block |
||
| 233 | 233 | $ord = $this->stream->ord(); |
| 234 | 234 | $this->stream->next(); |
| 235 | 235 | |
| 236 | - if($ord == 0) { // if end of record |
|
| 236 | + if ($ord == 0) { // if end of record |
|
| 237 | 237 | return; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | // comment starts |
| 241 | - if($ord === 59) { |
|
| 241 | + if ($ord === 59) { |
|
| 242 | 242 | $this->commentOpen = true; |
| 243 | 243 | goto start; |
| 244 | - } elseif($this->commentOpen == true && $ord !== 10) { |
|
| 244 | + } elseif ($this->commentOpen == true && $ord !== 10) { |
|
| 245 | 245 | $this->commentOpen = true; |
| 246 | 246 | goto start; |
| 247 | - } elseif($this->commentOpen == true && ($ord === 10 || $ord === 0)) { |
|
| 247 | + } elseif ($this->commentOpen == true && ($ord === 10 || $ord === 0)) { |
|
| 248 | 248 | $this->stream->previous(); |
| 249 | 249 | $this->commentOpen = false; |
| 250 | 250 | goto start; |
| 251 | 251 | } else { |
| 252 | 252 | // ignore blanck line |
| 253 | - if($ord === 32) { |
|
| 253 | + if ($ord === 32) { |
|
| 254 | 254 | goto start; |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | // Find starts of char set |
| 258 | - if($ord === 34 && !$this->commentOpen) { // " |
|
| 258 | + if ($ord === 34 && !$this->commentOpen) { // " |
|
| 259 | 259 | $this->extractCharSet($tokenName); |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | // multi line opened |
| 263 | - if($ord === 40 && !$this->commentOpen) { |
|
| 263 | + if ($ord === 40 && !$this->commentOpen) { |
|
| 264 | 264 | $this->multiLineOpened = true; |
| 265 | 265 | goto start; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | // multi line closed |
| 269 | - if($this->multiLineOpened && !$this->commentOpen && $ord === 41) { |
|
| 269 | + if ($this->multiLineOpened && !$this->commentOpen && $ord === 41) { |
|
| 270 | 270 | $this->multiLineOpened = false; |
| 271 | 271 | goto start; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | // comment end in multi line TXT record |
| 275 | - if($ord === 10 && $this->commentOpen && $this->multiLineOpened) { |
|
| 275 | + if ($ord === 10 && $this->commentOpen && $this->multiLineOpened) { |
|
| 276 | 276 | goto start; |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | // is record ends? |
| 280 | - if(!$this->multiLineOpened && ($ord === 10 || $ord === 0)) { |
|
| 280 | + if (!$this->multiLineOpened && ($ord === 10 || $ord === 0)) { |
|
| 281 | 281 | return; |
| 282 | - } elseif($this->multiLineOpened && $ord === 10) { |
|
| 282 | + } elseif ($this->multiLineOpened && $ord === 10) { |
|
| 283 | 283 | goto start; |
| 284 | 284 | } |
| 285 | 285 | } |
@@ -295,11 +295,11 @@ discard block |
||
| 295 | 295 | $ord = $this->stream->ord(); |
| 296 | 296 | $this->stream->next(); |
| 297 | 297 | |
| 298 | - if($ord == 0) { // if end of record |
|
| 298 | + if ($ord == 0) { // if end of record |
|
| 299 | 299 | return; |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | - if(!$escaping_open && $ord === 34) { |
|
| 302 | + if (!$escaping_open && $ord === 34) { |
|
| 303 | 303 | $this->txtExtractor($tokenName); |
| 304 | 304 | } else { |
| 305 | 305 | $this->tokens[$tokenName] .= chr($ord); |
@@ -147,7 +147,7 @@ |
||
| 147 | 147 | private function extractRecord() |
| 148 | 148 | { |
| 149 | 149 | $isFirst = $this->recordsAmmount === 0; |
| 150 | - if(! $isFirst ) { |
|
| 150 | + if (!$isFirst) { |
|
| 151 | 151 | $lastParsedRecord = end($this->tokens); |
| 152 | 152 | $previousName = $lastParsedRecord['NAME']; |
| 153 | 153 | } else { |