/** * Set a cookie * * {@inheritdoc} * * A value may either be a string or a ResponseCookie instance * String values will be converted into a ResponseCookie with * the "name" of the cookie being set from the "key" * * Obviously, the developer is free to organize this collection * however they like, and can be more explicit by passing a more * suggested "$key" as the cookie's "domain" and passing in an * instance of a ResponseCookie as the "$value" * * @see DataCollection::set() * @param string $key The name of the cookie to set * @param ResponseCookie|string $value The value of the cookie to set * @access public * @return ResponseCookieDataCollection */ public function set($key, $value) { if (!$value instanceof ResponseCookie) { $value = new ResponseCookie($key, $value); } return parent::set($key, $value); }
/** * Set a route * * {@inheritdoc} * * A value may either be a callable or a Route instance * Callable values will be converted into a Route with * the "name" of the route being set from the "key" * * A developer may add a named route to the collection * by passing the name of the route as the "$key" and an * instance of a Route as the "$value" * * @see DataCollection::set() * @param string $key The name of the route to set * @param Route|callable $value The value of the route to set * @return RouteCollection */ public function set($key, $value) { if (!$value instanceof Route) { $value = new Route($value); } return parent::set($key, $value); }
/** * Magic "__unset" method * * Allows the ability to arbitrarily remove a parameter from this instance * while treating it as an instance property * * @param string $param The name of the parameter * @access public * @return void */ public function __unset($param) { $this->params_named->remove($param); }
/** * Magic "__unset" method * * Allows the ability to arbitrarily remove shared data from this instance * while treating it as an instance property * * @param string $key The name of the shared data * @access public * @return void */ public function __unset($key) { $this->shared_data->remove($key); }
public function testArrayAccessSet() { // Test data $data = array('dog' => 'cooper'); // Create our collection with NO data $data_collection = new DataCollection(); // Set our data from our test data $data_collection[key($data)] = current($data); // Make sure the set worked $this->assertSame(current($data), $data_collection->get(key($data))); }