RouteParser.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace FastRoute;
  3. interface RouteParser
  4. {
  5. /**
  6. * Parses a route string into multiple route data arrays.
  7. *
  8. * The expected output is defined using an example:
  9. *
  10. * For the route string "/fixedRoutePart/{varName}[/moreFixed/{varName2:\d+}]", if {varName} is interpreted as
  11. * a placeholder and [...] is interpreted as an optional route part, the expected result is:
  12. *
  13. * [
  14. * // first route: without optional part
  15. * [
  16. * "/fixedRoutePart/",
  17. * ["varName", "[^/]+"],
  18. * ],
  19. * // second route: with optional part
  20. * [
  21. * "/fixedRoutePart/",
  22. * ["varName", "[^/]+"],
  23. * "/moreFixed/",
  24. * ["varName2", [0-9]+"],
  25. * ],
  26. * ]
  27. *
  28. * Here one route string was converted into two route data arrays.
  29. *
  30. * @param string $route Route string to parse
  31. *
  32. * @return mixed[][] Array of route data arrays
  33. */
  34. public function parse($route);
  35. }