for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Onoi\EventDispatcher;
use InvalidArgumentException;
/**
* Generic context that can be added during the dispatch process to be
* accessible to each invoked listener
*
* @license GNU GPL v2+
* @since 1.0
* @author mwjames
*/
class DispatchContext {
* @var array
private $container = array();
* @since 1.1
* @param array $container
* @return DispatchContext
public static function newFromArray( array $container ) {
$dispatchContext = new DispatchContext();
foreach ( $container as $key => $value ) {
$dispatchContext->set( $key, $value );
}
return $dispatchContext;
* @param string $key
* @return boolean
public function has( $key ) {
return isset( $this->container[strtolower( $key )] );
* @param mixed $value
public function set( $key, $value ) {
$this->container[strtolower( $key )] = $value;
* @return mixed
* @throws InvalidArgumentException
public function get( $key ) {
if ( $this->has( $key ) ) {
return $this->container[strtolower( $key )];
throw new InvalidArgumentException( "{$key} is unknown" );
public function isPropagationStopped() {
return $this->has( 'propagationstop' ) ? $this->get( 'propagationstop' ) : false;