class RouteCollection implements \IteratorAggregate, \Countable
{
/**
* @var Route[]
*/
private $routes = array();
public function add($name, Route $route)
{
unset($this->routes[$name]);
$this->routes[$name] = $route;
}
public function remove($name)
{
foreach ((array) $name as $n) {
unset($this->routes[$n]);
}
}
}
This is a piece of code from the class Symfony\Component\Routing\RouteCollection
. Does unset before the assignment matter?
Why is it done?
Second question: Why in remove method simple string is parsed to array?
Why I can't use simply:
unset($this->routes[$name]);
Same as in add method?