Created
May 7, 2013 20:23
-
-
Save BIGjuevos/5535798 to your computer and use it in GitHub Desktop.
Ruler replacement for context that doesn't rely on Pimple.
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 Ruler; | |
class Context implements \ArrayAccess | |
{ | |
private $values = array(); | |
public function __construct(array $values = array()) | |
{ | |
$this->values = $values; | |
} | |
public function offsetExists($offset) { | |
return isset( $this->values[$offset]); | |
} | |
public function offsetGet($offset) { | |
if ( is_callable( $this->values[$offset] ) ){ | |
return $this->values[$offset]($this); | |
} else { | |
return $this->values[$offset]; | |
} | |
} | |
public function offsetSet($offset, $value) { | |
$this->values[$offset] = $value; | |
} | |
public function offsetUnset($offset) { | |
unset( $this->values[$offset] ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment