Example #1
0
 /**
  * Format route output to command line.
  *
  * @param Route  $route
  * @param Output $output
  * @param        $type
  */
 public function formatOutput(Route $route, Output $output, $type = self::STYLE_DETAIL)
 {
     switch ($type) {
         case self::STYLE_DETAIL:
             $output->write('Route [');
             $output->write('<success>"' . $route->getName() . '"</success>');
             $output->writeln(']');
             $output->writeln("Path:\t\t" . str_replace('//', '/', $route->getPath()));
             $output->writeln("Method:\t\t" . $route->getMethod());
             $output->writeln("Format:\t\t" . implode(', ', $route->getFormats()));
             $output->writeln("Callback:\t" . (is_callable($route->getCallback()) ? 'Closure' : $route->getCallback()));
             $output->writeln("Defaults:\t" . implode(', ', $route->getDefaults()));
             $output->writeln("Requirements:\t" . implode(', ', $route->getRequirements()));
             $output->writeln("Path-Regex:\t" . $route->getPathRegex());
             $output->writeln('');
             break;
         case self::STYLE_LIST:
         default:
             $name = $route->getName();
             $method = $route->getMethod();
             $schema = $route->getScheme() ?? 'http';
             $path = $route->getPath();
             $output->write($name . str_repeat(' ', 25 - strlen($name)));
             $output->write($method . str_repeat(' ', 15 - strlen($method)));
             $output->write($schema . str_repeat(' ', 15 - strlen($schema)));
             $output->writeln($path);
     }
     return;
 }