36 lines
609 B
PHP
36 lines
609 B
PHP
<?php
|
|
namespace nur\sery\wip\php\access;
|
|
|
|
/**
|
|
* Class ValueAccess: accès à une valeur scalaire
|
|
*/
|
|
class ValueAccess extends AbstractAccess {
|
|
function __construct(&$dest) {
|
|
$this->dest =& $dest;
|
|
}
|
|
|
|
/** @var mixed */
|
|
protected $dest;
|
|
|
|
function exists(): bool {
|
|
return $this->dest !== null;
|
|
}
|
|
|
|
function available(): bool {
|
|
return $this->exists();
|
|
}
|
|
|
|
function get($default=null) {
|
|
if ($this->dest === null) return $default;
|
|
else return $this->dest;
|
|
}
|
|
|
|
function set($value): void {
|
|
$this->dest = $value;
|
|
}
|
|
|
|
function del(): void {
|
|
$this->dest = null;
|
|
}
|
|
}
|