bugs
This commit is contained in:
parent
52631cc977
commit
3550730a9f
|
@ -141,6 +141,15 @@ class cl {
|
||||||
return $array !== null? array_keys($array): [];
|
return $array !== null? array_keys($array): [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* retourner la première valeur de $array ou $default si le tableau est null
|
||||||
|
* ou vide
|
||||||
|
*/
|
||||||
|
static final function first($array, $default=null) {
|
||||||
|
if (is_array($array)) return $array[array_key_first($array)];
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,8 +7,8 @@ namespace nur\sery\os;
|
||||||
*/
|
*/
|
||||||
class EOFException extends IOException {
|
class EOFException extends IOException {
|
||||||
static final function ensure_not_eof($data, bool $throw=true, $eof=false) {
|
static final function ensure_not_eof($data, bool $throw=true, $eof=false) {
|
||||||
if (!$throw) return null;
|
if ($data !== $eof) return $data;
|
||||||
elseif ($data !== $eof) return $data;
|
elseif (!$throw) return null;
|
||||||
else throw new self();
|
else throw new self();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,8 @@ class IOException extends RuntimeException {
|
||||||
}
|
}
|
||||||
|
|
||||||
static final function ensure_valid($value, bool $throw=true, $invalid=false) {
|
static final function ensure_valid($value, bool $throw=true, $invalid=false) {
|
||||||
if (!$throw) return null;
|
if ($value !== $invalid) return $value;
|
||||||
elseif ($value !== $invalid) return $value;
|
elseif (!$throw) return null;
|
||||||
else throw self::error();
|
else throw self::error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue