Esempio n. 1
0
 /**
  * Overrides the default behavior of offsetSet so that when setting an entry
  * the type and index type are checked
  * @param string|int $index
  * @param mixed      $value
  * @return void
  */
 public function offsetSet($index, $value)
 {
     if (is_string($value) && null !== ($value = \Nimbles\Http\Header::factory($index, $value, true))) {
         $index = $value->getName();
     }
     if (null === $value) {
         return;
     }
     parent::offsetSet($index, $value);
 }
Esempio n. 2
0
 /**
  * Overloads offsetSet to restrict value type
  * @param  int|string      $key
  * @param  \Nimbles\Http\Cookie $value
  * @return void
  * @throws \Nimbles\Http\Cookie\Exception\InvalidInstance
  */
 public function offsetSet($key, $value)
 {
     if (is_string($value)) {
         $value = new Cookie(array('name' => $key, 'value' => $value));
     }
     if (!$value instanceof Cookie) {
         throw new Cookie\Exception\InvalidInstance('Invalid value, must be an instance of Nimbles\\Http\\Cookie');
     }
     if (null === $value->getName()) {
         $value->setName($key);
     }
     return parent::offsetSet($value->getName(), $value);
 }