Skip to content

Instantly share code, notes, and snippets.

@coreymcmahon
Created July 12, 2014 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coreymcmahon/724f1706dd331ec88ebd to your computer and use it in GitHub Desktop.
Save coreymcmahon/724f1706dd331ec88ebd to your computer and use it in GitHub Desktop.
Mocking the Filesystem during BDD with Behat and PHPSpec - www.slashnode.com
<?php
class Config
{
protected $settings;
public function __construct($settings = array())
{
$this->settings = $settings;
}
public static function load($path)
{
$config = new static();
if (file_exists($path))
return new static(include $path);
return new static;
}
public function get($key, $default = null)
{
if (isset($this->settings[$key]))
return $this->settings[$key];
return $default;
}
public function set($key, $value)
{
$this->settings[$key] = $value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment