1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48:
<?php
namespace Comprobo\Verify;
/**
* In-memory application state, shared between internal classes
*
* @see Factory
*/
class State
{
private $state = [];
/**
* Set a value in the current execution context
* @param string $key
* @param mixed $value
*/
public function set($key, $value)
{
if (!is_string($key)) {
throw new Exceptions\Misconfiguration("State keys must be strings");
}
$this->state[$key] = $value;
}
/**
* retrieve a value from the current execution context
*
* @param string $key
* @return mixed the stored value or null if not found
*/
public function get($key)
{
return $this->has($key) ? $this->state[$key] : null;
}
/**
* determine whether a key is set
* @param string $key
* @return bool key exists
*/
public function has($key)
{
return array_key_exists($key, $this->state);
}
}