<?php namespace nur\sery\db; /** * Class AbstractCapacitor: implémentation de base d'un {@link ICapacitor} */ abstract class AbstractCapacitor implements ICapacitor { abstract protected function getChannel(?string $name): CapacitorChannel; abstract function _exists(CapacitorChannel $channel): bool; /** tester si le canal spécifié existe */ function exists(?string $channel): bool { return $this->_exists($this->getChannel($channel)); } abstract function _reset(CapacitorChannel $channel): void; /** supprimer le canal spécifié */ function reset(?string $channel): void { $this->_reset($this->getChannel($channel)); } abstract function _charge(CapacitorChannel $channel, $item, ?callable $func, ?array $args): bool; function charge(?string $channel, $item, ?callable $func=null, ?array $args=null): bool { return $this->_charge($this->getChannel($channel), $item, $func, $args); } abstract function _discharge(CapacitorChannel $channel, $filter, ?bool $reset): iterable; function discharge(?string $channel, $filter=null, ?bool $reset=null): iterable { return $this->_discharge($this->getChannel($channel), $filter, $reset); } abstract function _get(CapacitorChannel $channel, $filter); function get(?string $channel, $filter) { return $this->_get($this->getChannel($channel), $filter); } abstract function _each(CapacitorChannel $channel, $filter, callable $func, ?array $args): void; function each(?string $channel, $filter, callable $func, ?array $args=null): void { $this->_each($this->getChannel($channel), $filter, $func, $args); } abstract function close(): void; }