Simple PHP Key-Value DataStore
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
<?php | |
namespace Bramus; | |
/** | |
* Simple Key-Value DataStore to keep variables on | |
*/ | |
class Datastore { | |
private $data = array(); | |
public function __get($name) { | |
return isset($this->data[$name]) ? $this->data[$name] : null; | |
} | |
public function __set($name, $value) { | |
$this->data[$name] = $value; | |
} | |
public function __call($name, $args) { | |
return isset($this->data[$name]) ? $this->data[$name] : (isset($args[0]) ? $args[0] : null); | |
} | |
} | |
// EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage