Example #1
0
 /**
  * helper function to capitalise our route pattern 
  *
  * @param route object A Route object instance to be used 
  *
  * @return void
  */
 public static function namespaceRoutePattern(Route $route)
 {
     //get our class pattern by seperating the string at the '::'
     list($class, $method) = explode('::', $route->pattern_mapped);
     //make sure our namespace is capitalised properly
     if (strpos($class, '\\') !== false) {
         //clean up any remaining / and replace with \
         $class = '\\' . str_replace('/', '\\', $class);
         //explode array and filter empty slots
         $sections = array_filter(explode('\\', $class));
         //reset our new array
         $array = array();
         //capitalise each work
         foreach ($sections as $key => $section) {
             //if we have a / skip this one
             if (trim($section) == '/') {
                 continue;
             }
             //add to our new array
             $array[$key] = ucwords($section);
         }
         //create our new class name from the sections
         $class = implode('\\', $array);
         //update our mapped route
         $route->setMappedPattern($class . '::' . $method);
     }
     return $route;
 }