Skip to content

Instantly share code, notes, and snippets.

@exts
Last active December 28, 2015 14:51
Show Gist options
  • Save exts/d96455494a3e79b7dbe0 to your computer and use it in GitHub Desktop.
Save exts/d96455494a3e79b7dbe0 to your computer and use it in GitHub Desktop.
interface ConfigFileInterface
{
public function load();
public function save();
}
class YamlConfigFile implements ConfigFileInterface
{
public function load()
{
}
public function save()
{
}
}
class ConfigFile implements \ArrayAccess
{
/**
* @var ConfigFileInterface
*/
protected $config;
/**
* @param ConfigFileInterface
*/
public function __construct(ConfigFileInterface $config)
{
$this->config = $config;
}
}
$config = new ConfigFile(
YamlConfigFile('config.yml')
);
echo $config['timeout']; // 10
echo $config['parameter']['a']; // 1;
echo $config->get('name'); // abc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment