@@ -55,26 +55,27 @@ public function setPrefix($prefix)
55
55
public function addPrefixRoute (DumperRoute $ route )
56
56
{
57
57
$ prefix = $ route ->getRoute ()->compile ()->getStaticPrefix ();
58
+ $ collection = $ this ;
58
59
59
60
// Same prefix, add to current leave
60
- if ($ this ->prefix === $ prefix ) {
61
- $ this ->add ($ route );
61
+ if ($ collection ->prefix === $ prefix ) {
62
+ $ collection ->add ($ route );
62
63
63
- return $ this ;
64
+ return $ collection ;
64
65
}
65
66
66
67
// Prefix starts with route's prefix
67
- if ('' === $ this ->prefix || 0 === strpos ($ prefix , $ this ->prefix )) {
68
- $ collection = new DumperPrefixCollection ();
69
- $ collection ->setPrefix (substr ($ prefix , 0 , strlen ($ this ->prefix )+1 ));
70
- $ this ->add ($ collection );
68
+ if ('' === $ collection ->prefix || 0 === strpos ($ prefix , $ collection ->prefix )) {
69
+ $ child = new DumperPrefixCollection ();
70
+ $ child ->setPrefix (substr ($ prefix , 0 , strlen ($ collection ->prefix )+1 ));
71
+ $ collection ->add ($ child );
71
72
72
- return $ collection ->addPrefixRoute ($ route );
73
+ return $ child ->addPrefixRoute ($ route );
73
74
}
74
75
75
76
// No match, fallback to parent (recursively)
76
77
77
- if (null === $ parent = $ this ->getParent ()) {
78
+ if (null === $ parent = $ collection ->getParent ()) {
78
79
throw new \LogicException ("The collection root must not have a prefix " );
79
80
}
80
81
0 commit comments