private function getDateAttribute(ItemInterface $item)
{
$attributes = $item->getAttributes();
if (isset($attributes['date']) === false) {
throw new MissingAttributeException('Attribute date required.', 'date', $item->getPath());
}
if (is_string($attributes['date']) === false) {
throw new AttributeValueException('Invalid value. Expected date string.', 'date', $item->getPath());
}
try {
return new \DateTime($attributes['date']);
} catch (\Exception $e) {
throw new AttributeValueException('Invalid value. Expected date string.', 'date', $item->getPath());
}
}