Example #1
0
/**
 * @param array $args
 */
function bind(array $args)
{
    $tracer = new Tracer(__FUNCTION__, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, DEBUG_BACKTRACE_LEVEL));
    foreach ($args as $name => $value) {
        $entry = new Entry($name, $tracer);
        enforce(!Registry::Instance()->exists($entry->hash))->orThrow('Constant "%s" already exists', $name);
        $entry->be($value);
    }
}
Example #2
0
 /**
  * @param $value
  */
 public function be($value)
 {
     ensure($this->value)->isNull()->orThrow('Constant "%s" is already assigned', $this->name);
     $this->value = $value;
     Registry::Instance()->register($this);
 }