\d+\.\d+)$/', $value, $matches)) { $header->setVersion($matches['version']); } return $header; } /** * @return string */ public function getFieldName() { return 'MIME-Version'; } /** * @inheritDoc */ public function getFieldValue($format = HeaderInterface::FORMAT_RAW) { return $this->version; } /** * @param string $encoding * @return self */ public function setEncoding($encoding) { // This header must be always in US-ASCII return $this; } /** * @return string */ public function getEncoding() { return 'ASCII'; } /** * @return string */ public function toString() { return 'MIME-Version: ' . $this->getFieldValue(); } /** * Set the version string used in this header * * @param string $version * @return MimeVersion */ public function setVersion($version) { if (! preg_match('/^[1-9]\d*\.\d+$/', $version)) { throw new Exception\InvalidArgumentException('Invalid MIME-Version value detected'); } $this->version = $version; return $this; } /** * Retrieve the version string for this header * * @return string */ public function getVersion() { return $this->version; } }