33 lines
883 B
PHP
33 lines
883 B
PHP
|
<?php # -*- coding: utf-8 mode: php -*- vim:sw=2:sts=2:et:ai:si:sta:fenc=utf-8
|
||
|
namespace nur;
|
||
|
|
||
|
use nur\b\values\Mparams;
|
||
|
|
||
|
/**
|
||
|
* Class P: gestion des paramètres $_POST
|
||
|
*/
|
||
|
class P extends Mparams {
|
||
|
/** 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, $_POST);
|
||
|
}
|
||
|
|
||
|
/** obtenir le paramètre $name */
|
||
|
static final function get($name, $default=null, bool $trim=false) {
|
||
|
$value = A::get($_POST, $name, $default);
|
||
|
if ($trim) $value = str::trim($value);
|
||
|
return $value;
|
||
|
}
|
||
|
|
||
|
/** modifier le paramètre. */
|
||
|
static final function set(string $name, ?string $value): void {
|
||
|
$_POST[$name] = $value;
|
||
|
}
|
||
|
|
||
|
/** obtenir le corps de la requête POST */
|
||
|
static final function raw(): string {
|
||
|
return file_get_contents("php://input");
|
||
|
}
|
||
|
}
|