155 public function add( $template, $userData ) {
157 $parts = explode(
'/', $template );
158 $length = count( $parts );
159 if ( !isset( $this->treesByLength[$length] ) ) {
160 $this->treesByLength[$length] = [];
162 $tree =& $this->treesByLength[$length];
165 for ( $i = 1; $i < $length - 1; $i++ ) {
166 if ( $parts[$i] ==
'' ) {
171 $conflict = $this->findConflict( $tree, $parts );
172 if ( $conflict !==
false ) {
173 throw new PathConflict( $template, $userData, $conflict );
177 foreach ( $parts as $index => $part ) {
178 $paramName = $this->getParamName( $part );
179 if ( $paramName !==
false ) {
185 if ( $index === $length - 1 ) {
187 'template' => $template,
189 'userData' => $userData
191 } elseif ( !isset( $tree[$key] ) ) {
194 $tree =& $tree[$key];