Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > 5326190fc690eb59f6575c01243b0085 > files > 129

php-apc-3.1.15-4.14.mga4.x86_64.rpm

<?php

namespace Symfony\Component\EventDispatcher;

class GenericEvent extends Event implements \ArrayAccess
{
    protected $subject;
    protected $arguments;
    public function __construct($subject = null, array $arguments = array())
    {
        $this->subject = $subject;
        $this->arguments = $arguments;
    }

    public function getSubject()
    {
        return $this->subject;
    }

    public function getArgument($key)
    {
        if ($this->hasArgument($key)) {
            return $this->arguments[$key];
        }

        throw new \InvalidArgumentException(sprintf('%s not found in %s', $key, $this->getName()));
    }

    public function setArgument($key, $value)
    {
        $this->arguments[$key] = $value;

        return $this;
    }

    public function getArguments()
    {
        return $this->arguments;
    }

    public function setArguments(array $args = array())
    {
        $this->arguments = $args;

        return $this;
    }

    public function hasArgument($key)
    {
        return array_key_exists($key, $this->arguments);
    }

    public function offsetGet($key)
    {
        return $this->getArgument($key);
    }

    public function offsetSet($key, $value)
    {
        $this->setArgument($key, $value);
    }

    public function offsetUnset($key)
    {
        if ($this->hasArgument($key)) {
            unset($this->arguments[$key]);
        }
    }

    public function offsetExists($key)
    {
        return $this->hasArgument($key);
    }
}