| 1: | <?php |
| 2: | |
| 3: | namespace LaravelUi5\Core\Introspection\App; |
| 4: | |
| 5: | /** |
| 6: | * Represents a UI5 routing entry as declared in the application manifest. |
| 7: | * |
| 8: | * This class intentionally models only the semantically relevant subset of a |
| 9: | * route definition for SDK-level introspection: |
| 10: | * |
| 11: | * - `name` : the stable identifier of the route, |
| 12: | * - `pattern` : the URL pattern used for navigation, |
| 13: | * - `target` : one or more target keys activated by the route. |
| 14: | * |
| 15: | * All additional UI5 routing options (e.g. transitions, callbacks, layouts) |
| 16: | * are deliberately ignored, as they are runtime concerns and not required for |
| 17: | * structural analysis or tooling purposes. |
| 18: | * |
| 19: | * @see https://sdk.openui5.org/#/topic/902313063d6f45aeaa3388cc4c13c34e |
| 20: | */ |
| 21: | final readonly class Ui5Route |
| 22: | { |
| 23: | public function __construct( |
| 24: | private string $name, |
| 25: | private string $pattern, |
| 26: | private string|array $target, |
| 27: | ) |
| 28: | { |
| 29: | } |
| 30: | |
| 31: | public function getName(): string |
| 32: | { |
| 33: | return $this->name; |
| 34: | } |
| 35: | |
| 36: | public function getPattern(): string |
| 37: | { |
| 38: | return $this->pattern; |
| 39: | } |
| 40: | |
| 41: | public function getTarget(): string|array |
| 42: | { |
| 43: | return $this->target; |
| 44: | } |
| 45: | |
| 46: | /** |
| 47: | * Returns whether the route pattern contains dynamic parameters. |
| 48: | * |
| 49: | * UI5 supports two parameter syntaxes in route patterns: |
| 50: | * - legacy syntax: :param: |
| 51: | * - modern syntax: {param} |
| 52: | * |
| 53: | * Routes containing either form are considered parameterized. |
| 54: | */ |
| 55: | public function hasParameters(): bool |
| 56: | { |
| 57: | return str_contains($this->pattern, ':') |
| 58: | || str_contains($this->pattern, '{'); |
| 59: | } |
| 60: | } |
| 61: |