Skip to content

Instantly share code, notes, and snippets.

@BIGjuevos
Created May 7, 2013 20:23
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 BIGjuevos/5535798 to your computer and use it in GitHub Desktop.
Save BIGjuevos/5535798 to your computer and use it in GitHub Desktop.
Ruler replacement for context that doesn't rely on Pimple.
<?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