Last active
December 28, 2015 14:51
-
-
Save exts/d96455494a3e79b7dbe0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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