setVersion($this->decodeVersion()); return $header; } /** * Decode version string * * @throws DecoderException * @return string */ protected function decodeVersion(): string { $parsed = (bool) preg_match("/^GIF(?P[0-9]{2}[a-z])$/", $this->getNextBytes(6), $matches); if ($parsed === false) { throw new DecoderException('Unable to parse file header.'); } return $matches['version']; } }