nulib/php/src_base/DataException.php

20 lines
466 B
PHP
Raw Normal View History

2024-03-22 13:19:28 +04:00
<?php
namespace nulib;
use RuntimeException;
/**
* Class DataException: exception générique concernant l'accès à des données
*/
class DataException extends RuntimeException {
static final function no_more_data(): self {
return new self("no more data");
}
static final function ensure_not_eof($data, bool $throw=true, $eof=false) {
if (!$throw) return null;
elseif ($data !== $eof) return $data;
else throw self::no_more_data();
}
}