Ejemplo n.º 1
0
 /**
  * Calling a container value as a method has two possible results; Like 'get'
  * if the key points to a callable object, it will return the result of that
  * callable, otherwise it will return the value of the key.
  * @param  string $key
  *  The key within the container
  * @param  array  $arguments
  *  Any arguments passed will be provided to a callable, after `$this`
  * @return mixed
  *  Whatever the value is in the container
  */
 public function __call($key, array $arguments = [])
 {
     if (!empty($arguments)) {
         return parent::offsetSet($key, $arguments[0]);
     }
     return $this->offsetGet($key);
 }
Ejemplo n.º 2
0
 /**
  * Set a key value pair
  * @param  mixed $key   The key
  * @param  mixed $value The value
  */
 public function offsetSet($key, $value)
 {
     return parent::offsetSet($key, is_array($value) ? new ArrayObject($value) : $value);
 }
Ejemplo n.º 3
0
 /**
  * Unset a value from the container using a provided key
  * @param  string $key
  *  The key to identify the item to unset
  */
 public function offsetUnset($key)
 {
     $values = array_replace($this->defaults, ['value' => '', 'expires' => time() - 86400]);
     $this->fresh->offsetSet($key, $this->create('FreshCookie', [$values]));
     $this->existing->offsetUnset($key);
 }