Created
July 12, 2014 08:13
-
-
Save coreymcmahon/724f1706dd331ec88ebd to your computer and use it in GitHub Desktop.
Mocking the Filesystem during BDD with Behat and PHPSpec - www.slashnode.com
This file contains hidden or 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
<?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