public function testSet() { $this->bag->set('foo', 'bar'); $this->assertArrayHasKey('foo', $this->property->getValue($this->bag)); $bag = $this->property->getValue($this->bag); $this->assertEquals('bar', $bag['foo']); }
/** * Set HTTP header value * * This method sets a header value. It replaces * any values that may already exist for the header name. * * @param string $key The case-insensitive header name * @param string $value The header value */ public function set($key, $value) { if (!is_array($value)) { $value = [$value]; } parent::set($this->normalizeKey($key), ['value' => $value, 'originalKey' => $key]); }
/** * Add data to key * * @param string $key The data key * @param mixed $value The data value * @api */ public function add($key, $value) { $header = $this->get($key, true); if (is_array($value)) { $header = array_merge($header, $value); } else { $header[] = $value; } parent::set($this->normalizeKey($key), $header); }
/** * Set cookie * * The second argument may be a single scalar value, in which case * it will be merged with the default settings and considered the `value` * of the merged result. * * The second argument may also be an array containing any or all of * the keys shown in the default settings above. This array will be * merged with the defaults shown above. * * @param string $key Cookie name * @param mixed $value Cookie settings * @api */ public function set($key, $value) { if (is_array($value)) { $settings = array_replace($this->defaults, $value); } else { $settings = array_replace($this->defaults, array('value' => $value)); } parent::set($key, $settings); }