Final Class Yiisoft\HttpMiddleware\HttpCache\LastModifiedProvider\PredefinedLastModifiedProvider
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Yiisoft\ |
Provides dates from a predefined collection. Useful for testing purposes.
Public Methods
Method Details
| public mixed __construct ( iterable $dates ) | ||
| $dates | iterable |
Predefined dates to be returned by the provider. |
public function __construct(iterable $dates)
{
$this->iterator = $this->createIterator($dates);
}
| public DateTimeImmutable get ( \ | ||
| $request | \ |
|
public function get(ServerRequestInterface $request): DateTimeImmutable
{
if (!$this->iterator->valid()) {
throw new OutOfBoundsException('No more dates available.');
}
/** @var DateTimeImmutable $date */
$date = $this->iterator->current();
$this->iterator->next();
return $date;
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.