diff --git a/wip/php/access/DoubleAccess.php b/wip/php/access/DoubleAccess.php index 69344af..7c889c7 100644 --- a/wip/php/access/DoubleAccess.php +++ b/wip/php/access/DoubleAccess.php @@ -15,4 +15,37 @@ namespace nur\sery\wip\php\access; * {@link IGetter} attaquent de nouveau $reader comme initialement */ class DoubleAccess extends AbstractAccess { + function __construct(IAccess $reader, IAccess $writer) { + $this->reader = $reader; + $this->writer = $writer; + $this->getter = $reader; + } + + protected IAccess $reader; + + protected IAccess $writer; + + protected IGetter $getter; + + function exists(): bool { + return $this->getter->exists(); + } + + function available(): bool { + return $this->getter->available(); + } + + function get($default=null) { + return $this->getter->get($default); + } + + function set($value): void { + $this->writer->set($value); + $this->getter = $this->writer; + } + + public function del(): void { + $this->writer->del(); + $this->getter = $this->reader; + } }