filicious / core

Filicious is a high level object oriented filesystem abstraction for PHP.
https://filicious.github.io/
31 stars 9 forks source link

Rework Config interface #64

Closed tristanlins closed 10 years ago

tristanlins commented 11 years ago

class Config

class Config
{
    /** @return Config */
    public function commit();
    /** @return bool */
    public function changed();
    /** @return Config */
    public function discard();
    /** @return Config */
    public function select($name = null) {
        $name = strval($name);
        return strlen($name) ? new ConfigContext($this, $name) : $this;
    }
    /** @return string */
    public function getContext()
    /** @return Config */
    public function addAdapter($config, &$name = null, $path = null, $insert = null);
    /** @return Config */
    public function set($param, $value = null)
    /** @return mixed */
    public function get($param, $default = null, $inherit = false);
    /** @return bool */
    public function has($param, $inherit = false)
    /** @return Filesystem */
    public function getFilesystem()
    /** @return Iterator [$name => $config] */
    public function getAdapters()
    public function serialize()
    public function unserialize($str)
    public function __clone()
    public function __toString()
}

class ConfigContext

class ConfigContext extends Config
{
    /** @var string */
    protected $context;

    /** @var Config */
    protected $config;

    /** @return Config */
    public function commit()
    {
        return $this->config->commit();
    }
    /** @return bool */
    public function changed()
    {
        return $this->config->changed();
    }
    /** @return Config */
    public function discard()
    {
        return $this->config->discard();
    }
    /** @return Config */
    public function select($name = null)
    {
        $name = strval($name);
        return $name === $this->context ? $this : $this->config->select($name);
    }
    /** @return string */
    public function getContext()
    {
        return $this->context;
    }
    /** @return Config */
    public function addAdapter($config, &$name = null, $path = null, $insert = null)
    {
        return $this->config->addAdapter(
            $config,
            $name,
            $path,
            $insert
        );
    }
    /** @return Config */
    public function set($param, $value = null)
    {
        return $this->config->set(
            $param,
            $value
        );
    }
    /** @return mixed */
    public function get($param, $default = null, $inherit = false)
    {
        return $this->config->set(
            $param,
            $default,
            $inherit
        );
    }
    /** @return bool */
    public function has($param, $inherit = false)
    {
        return $this->config->has(
            $param,
            $inherit
        );
    }
    /** @return Filesystem */
    public function getFilesystem()
    {
        return $this->config->getFilesystem();
    }
    /** @return Iterator [$name => $config] */
    public function getAdapters()
    {
        return $this->config->getAdapters();
    }
    public function serialize()
    {
        return $this->config->serialize();
    }
    public function unserialize($str)
    {
        return $this->config->unserialize($str);
    }
    public function __clone()
    {
        return $this->config->__clone();
    }
    public function __toString()
    {
        return $this->config->__toString();
    }
}
tristanlins commented 10 years ago

Not needed anymore, see #78