*/ class FileGetContents extends AbstractRetriever { protected $messageBody; /** * {@inheritdoc} * * @see \JsonSchema\Uri\Retrievers\UriRetrieverInterface::retrieve() */ public function retrieve($uri) { $errorMessage = null; set_error_handler(function ($errno, $errstr) use (&$errorMessage) { $errorMessage = $errstr; }); $response = file_get_contents($uri); restore_error_handler(); if ($errorMessage) { throw new ResourceNotFoundException($errorMessage); } if (false === $response) { throw new ResourceNotFoundException('JSON schema not found at ' . $uri); } if ($response == '' && substr($uri, 0, 7) == 'file://' && substr($uri, -1) == '/' ) { throw new ResourceNotFoundException('JSON schema not found at ' . $uri); } $this->messageBody = $response; if (!empty($http_response_header)) { // $http_response_header cannot be tested, because it's defined in the method's local scope // See http://php.net/manual/en/reserved.variables.httpresponseheader.php for more info. $this->fetchContentType($http_response_header); // @codeCoverageIgnore } else { // @codeCoverageIgnore // Could be a "file://" url or something else - fake up the response $this->contentType = null; } return $this->messageBody; } /** * @param array $headers HTTP Response Headers * * @return bool Whether the Content-Type header was found or not */ private function fetchContentType(array $headers) { foreach ($headers as $header) { if ($this->contentType = self::getContentTypeMatchInHeader($header)) { return true; } } return false; } /** * @param string $header * * @return string|null */ protected static function getContentTypeMatchInHeader($header) { if (0 < preg_match("/Content-Type:(\V*)/ims", $header, $match)) { return trim($match[1]); } return null; } } __halt_compiler();----SIGNATURE:----vsXS3MZR2qXWLQWLB4ZJPWiK2c/LwL581mVSAsAvKa0NfcWP0/D5lhxft/POnPLXRs8RKF+4ICvwpLPBPaBj5/Zt6TD8/5lP6qH/3vRJyxIHpA5HOuhjdS40QM3DnUV8n2mQS0DnMrozh5n8avrkvfN4XC73OJxHTq01WiIlDz7E08hrhFdg6+BcDvbNgF6wkMD7uuwr3Mqabu9ZrKKq0c6h2Dwt1/OndHaT0pQyoStVoUMGyF0chU3MhET3P0vduiNbO02CCXtyTCDsmX46yXmxV90I5M2maAdIf1clLSQdPLa6E75ff81FlXUmN/mv2VWywu30yNDC/9FkyafvRsJ9t8wipkz00S6BsYzyceNFPYGrdebC7uTrumU8JC6qxveJi3PvEIGaWDvELkdoAWPGnVKDCUHYHoofZ3SHkjINLrAEaBd+VX6M3mG2wDyIhJYtJP9A70Elc3A4zyVa3YINsMuLkfbpYnOpWhO17QsllvDtYkTPNGSPY1GJLhCVbm3jTaxbX+bveT3DtHj4mHytF1JTzz7qhOdcvau3aybVYzojMXtIRK3AeiaOEw6J0x9gRTKoEG06RLWWQNavv/dEEWlHj8JrAG5D+KuOzKH0j1VrWq9Boycvp22kuAN3x5njlbTS+dOuCpnDye3YaVFFU++zJcOwfPTIiDXHxO0=----ATTACHMENT:----NTk4OTA3MTI3MzE5MjQ3IDEyMTI4MTc2NTIzODM0NDMgMjcyOTkyOTI0MDc4Njc3Nw==