modifs.mineures sans commentaires

This commit is contained in:
Jephté Clain 2024-06-07 17:10:57 +04:00
parent 6feb54dc22
commit d0b8be8132
3 changed files with 8 additions and 3 deletions

View File

@ -33,7 +33,9 @@ class cl {
*/
static final function first(?iterable $iterable, $default=null) {
if (is_array($iterable)) {
return $iterable[array_key_first($iterable)];
$key = array_key_first($iterable);
if ($key === null) return $default;
return $iterable[$key];
}
if (is_iterable($iterable)) {
foreach ($iterable as $value) {
@ -49,7 +51,9 @@ class cl {
*/
static final function last(?iterable $iterable, $default=null) {
if (is_array($iterable)) {
return $iterable[array_key_last($iterable)];
$key = array_key_last($iterable);
if ($key === null) return $default;
return $iterable[$key];
}
$value = $default;
if (is_iterable($iterable)) {

View File

@ -151,6 +151,7 @@ class CapacitorChannel {
return $serial !== null? unserialize($serial): null;
}
const SERIAL_DEFINITION = "mediumtext";
const SUM_DEFINITION = "varchar(40)";
final function sum(?string $serial, $value=null): ?string {

View File

@ -30,7 +30,7 @@ abstract class CapacitorStorage {
const PRIMARY_KEY_DEFINITION = null;
const COLUMN_DEFINITIONS = [
"item__" => "text",
"item__" => CapacitorChannel::SERIAL_DEFINITION,
"item__sum_" => CapacitorChannel::SUM_DEFINITION,
"created_" => "datetime",
"modified_" => "datetime",