October\Rain\Router\Helper

Source: ~/vendor/october/rain/src/Router/Helper.php

Methods that may be useful for processing routing activity

Public methods

public static string getParameterName(string $segment)

Extracts the parameter name from a URL pattern segment definition.

Parameters
  • string $segment - The segment definition.

public static string getSegmentDefaultValue(string $segment)

Extracts the default parameter value from a URL pattern segment definition.

Parameters
  • string $segment - The segment definition.

public static string getSegmentRegExp(string $segment)

Extracts the regular expression from a URL pattern segment definition.

Parameters
  • string $segment - The segment definition.

public static string normalizeUrl(string $url)

Adds leading slash and removes trailing slash from the URL.

Parameters
  • string $url - URL to normalize.

public static string parseValues(stdObject $object, array $columns, string $string)

Replaces :column_name with it's object value. Example: /some/link/:id/:name -> /some/link/1/Joe

Parameters
  • stdObject $object - Object containing the data
  • array $columns - Expected key names to parse
  • string $string - URL template

public static string rebuildUrl(array $urlArray)

Rebuilds a URL from an array of segments.

Parameters
  • array $urlArray - Array the URL segments.

public static string replaceParameters(stdObject $object, string $string)

Replaces :column_name with object value without requiring a list of names. Example: /some/link/:id/:name -> /some/link/1/Joe

Parameters
  • stdObject $object - Object containing the data
  • string $string - URL template

public static boolean segmentIsOptional(string $segment)

Checks whether an URL pattern segment is optional.

Parameters
  • string $segment - The segment definition.

public static boolean segmentIsWildcard(string $segment)

Checks whether an URL pattern segment is a wildcard.

Parameters
  • string $segment - The segment definition.

public static array segmentizeUrl(string $url)

Splits an URL by segments separated by the slash symbol.

Parameters
  • string $url - URL to segmentize.