for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types = 1);
namespace Innmind\Rest\ServerBundle\RangeExtractor;
use Innmind\Rest\ServerBundle\Exception\RangeNotFoundException;
use Innmind\Rest\Server\Request\Range;
use Innmind\Http\Message\ServerRequestInterface;
final class HeaderExtractor implements ExtractorInterface
{
/**
* {@inheritdoc}
*/
public function extract(ServerRequestInterface $request): Range
if (!$request->headers()->has('Range')) {
throw new RangeNotFoundException;
}
return new Range(
$request
->headers()
->get('Range')
->values()
->current()
->firstPosition(),
->lastPosition()
);