Formatter should fail for invalid data
This commit is contained in:
parent
859d964d6b
commit
a79df3943a
|
@ -29,6 +29,8 @@
|
|||
|
||||
namespace Icinga\Util;
|
||||
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
|
||||
class Format
|
||||
{
|
||||
const STANDARD_IEC = 0;
|
||||
|
@ -99,6 +101,9 @@ class Format
|
|||
if (! $timestamp) {
|
||||
return '-';
|
||||
}
|
||||
if (! preg_match('~^\d+$~', $timestamp)) {
|
||||
throw new ProgrammingError(sprintf('"%s" is not a number', $timestamp));
|
||||
}
|
||||
$duration = time() - $timestamp;
|
||||
$prefix = '';
|
||||
if ($duration < 0) {
|
||||
|
|
Loading…
Reference in New Issue