Example #1
0
 /**
  * {@inheritdoc}
  */
 public function build(SetInterface $identities, ServerRequestInterface $request, HttpResource $definition, SpecificationInterface $specification = null, Range $range = null) : MapInterface
 {
     $map = new Map('string', HeaderInterface::class);
     if (!$definition->isRangeable()) {
         return $map;
     }
     $map = $map->put('Accept-Ranges', new AcceptRanges(new AcceptRangesValue('resources')));
     if (!$range instanceof Range) {
         return $map;
     }
     $length = $range->lastPosition() - $range->firstPosition();
     return $map->put('Content-Range', new ContentRange(new ContentRangeValue('resources', $range->firstPosition(), $last = $range->firstPosition() + $identities->size(), $identities->size() < $length ? $last : $last + $length)));
 }