Skip to content

Commit

Permalink
renamed variables - making next change more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-lb authored and fabpot committed Feb 10, 2014
1 parent 5fbcf88 commit e0cf244
Showing 1 changed file with 10 additions and 9 deletions.
Expand Up @@ -55,26 +55,27 @@ public function setPrefix($prefix)
public function addPrefixRoute(DumperRoute $route)
{
$prefix = $route->getRoute()->compile()->getStaticPrefix();
$collection = $this;

// Same prefix, add to current leave
if ($this->prefix === $prefix) {
$this->add($route);
if ($collection->prefix === $prefix) {
$collection->add($route);

return $this;
return $collection;
}

// Prefix starts with route's prefix
if ('' === $this->prefix || 0 === strpos($prefix, $this->prefix)) {
$collection = new DumperPrefixCollection();
$collection->setPrefix(substr($prefix, 0, strlen($this->prefix)+1));
$this->add($collection);
if ('' === $collection->prefix || 0 === strpos($prefix, $collection->prefix)) {
$child = new DumperPrefixCollection();
$child->setPrefix(substr($prefix, 0, strlen($collection->prefix)+1));
$collection->add($child);

return $collection->addPrefixRoute($route);
return $child->addPrefixRoute($route);
}

// No match, fallback to parent (recursively)

if (null === $parent = $this->getParent()) {
if (null === $parent = $collection->getParent()) {
throw new \LogicException("The collection root must not have a prefix");
}

Expand Down

0 comments on commit e0cf244

Please sign in to comment.