Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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