nur-sery/src/params/G.php

29 lines
670 B
PHP
Raw Normal View History

2023-11-10 09:25:27 +04:00
<?php
2023-11-10 09:47:06 +04:00
namespace nur\sery\params;
2023-11-10 09:25:27 +04:00
2023-11-10 09:47:06 +04:00
use nulib\cl;
use nulib\str;
2023-11-10 09:25:27 +04:00
/**
* Class G: gestion des paramètres $_GET
*/
2023-11-10 09:47:06 +04:00
class G {
2023-11-10 09:25:27 +04:00
/** tester si le paramètre $name existe */
static final function has($name): bool {
if ($name === null || $name === false) return false;
return array_key_exists($name, $_GET);
}
/** obtenir le paramètre $name */
static final function get($name, $default=null, bool $trim=false) {
2023-11-10 09:47:06 +04:00
$value = cl::get($_GET, $name, $default);
2023-11-10 09:25:27 +04:00
if ($trim) $value = str::trim($value);
return $value;
}
/** modifier le paramètre. */
static final function set(string $name, ?string $value): void {
$_GET[$name] = $value;
}
}