# CurrentRouteView

> Immutable current-route diagnostics for the composed Request view.

[API reference](/docs/api/index.md) › [Debug Core](/docs/extensions/debug-core/reference/index.md) › [Panel](/docs/extensions/debug-core/reference/panel/index.md) › [Request](/docs/extensions/debug-core/reference/panel/request/index.md) › [Routing](/docs/extensions/debug-core/reference/panel/request/routing/index.md) › CurrentRouteView

| final class | `PHPForge\Debug\Panel\Request\Routing\CurrentRouteView` |
| --- | --- |
| Source | [`src/Panel/Request/Routing/CurrentRouteView.php`](https://github.com/php-forge/debug-core/blob/main/src/Panel/Request/Routing/CurrentRouteView.php#L10) |

Immutable current-route diagnostics for the composed Request view.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Creates current-route diagnostics for the supplied route. | `CurrentRouteView` |
| [`create()`](#method-create) static | Creates current-route diagnostics ready for immutable enrichment. | `CurrentRouteView` |
| [`getAction()`](#method-getAction) | Returns the handler the request dispatched to. | `CurrentRouteView` |
| [`getDefinition()`](#method-getDefinition) | Returns the route definition the request matched. | `CurrentRouteView` |
| [`getError()`](#method-getError) | Returns the routing failure reported while resolving the request. | `CurrentRouteView` |
| [`getMessage()`](#method-getMessage) | Returns the resolution summary shown above the routing trace. | `CurrentRouteView` |
| [`getParameters()`](#method-getParameters) | Returns the parameters bound to the resolved route. | `CurrentRouteView` |
| [`getRoute()`](#method-getRoute) | Returns the route the request resolved to. | `CurrentRouteView` |
| [`getTrace()`](#method-getTrace) | Returns the routing rules inspected while resolving the request. | `CurrentRouteView` |
| [`withAction()`](#method-withAction) | Returns a copy carrying another dispatched handler. | `CurrentRouteView` |
| [`withDefinition()`](#method-withDefinition) | Returns a copy carrying another route definition. | `CurrentRouteView` |
| [`withError()`](#method-withError) | Returns a copy carrying another routing failure. | `CurrentRouteView` |
| [`withMessage()`](#method-withMessage) | Returns a copy carrying another resolution summary. | `CurrentRouteView` |
| [`withParameters()`](#method-withParameters) | Returns a copy carrying another set of route parameters. | `CurrentRouteView` |
| [`withTrace()`](#method-withTrace) | Returns a copy carrying another routing trace. | `CurrentRouteView` |

## Method details

### __construct() <span id="method-__construct"></span>

```php
public function __construct(string $route = '')
```

Creates current-route diagnostics for the supplied route.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$route` | `string` | Route the request resolved to, as the application declares it. |

### create() <span id="method-create"></span>

```php
public static function create(string $route = ''): self
```

Creates current-route diagnostics ready for immutable enrichment.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$route` | `string` | Route the request resolved to, as the application declares it. |

**Returns**

`self`: View carrying only the resolved route.

### getAction() <span id="method-getAction"></span>

```php
public function getAction(): string|null
```

Returns the handler the request dispatched to.

**Returns**

`string|null`: Handler the request dispatched to, or `null` when the adapter exposes none.

### getDefinition() <span id="method-getDefinition"></span>

```php
public function getDefinition(): PHPForge\Debug\Panel\Request\Routing\RouteDefinition|null
```

Returns the route definition the request matched.

**Returns**

[`RouteDefinition`](/docs/extensions/debug-core/reference/panel/request/routing/routedefinition/index.md)`|null`: Matched route definition, or `null` when the adapter exposes none.

### getError() <span id="method-getError"></span>

```php
public function getError(): string|null
```

Returns the routing failure reported while resolving the request.

**Returns**

`string|null`: Routing failure message, or `null` when resolution succeeded.

### getMessage() <span id="method-getMessage"></span>

```php
public function getMessage(): string|null
```

Returns the resolution summary shown above the routing trace.

**Returns**

`string|null`: Resolution summary, or `null` when the adapter captured none.

### getParameters() <span id="method-getParameters"></span>

```php
public function getParameters(): array<array-key, mixed>
```

Returns the parameters bound to the resolved route.

**Returns**

`array<array-key, mixed>`: Parameters bound to the resolved route.

### getRoute() <span id="method-getRoute"></span>

```php
public function getRoute(): string
```

Returns the route the request resolved to.

**Returns**

`string`: Route the request resolved to, as the application declares it.

### getTrace() <span id="method-getTrace"></span>

```php
public function getTrace(): list<PHPForge\Debug\Panel\Request\Routing\RouteTraceRow>
```

Returns the routing rules inspected while resolving the request.

**Returns**

`list<`[`RouteTraceRow`](/docs/extensions/debug-core/reference/panel/request/routing/routetracerow/index.md)`>`: Routing rules inspected while resolving the request.

### withAction() <span id="method-withAction"></span>

```php
public function withAction(string|null $action): self
```

Returns a copy carrying another dispatched handler.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$action` | `string\|null` | Handler the request dispatched to, or `null` when the adapter exposes none. |

**Returns**

`self`: View with the action applied.

### withDefinition() <span id="method-withDefinition"></span>

```php
public function withDefinition(PHPForge\Debug\Panel\Request\Routing\RouteDefinition|null $definition): self
```

Returns a copy carrying another route definition.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$definition` | [`RouteDefinition`](/docs/extensions/debug-core/reference/panel/request/routing/routedefinition/index.md)`\|null` | Route definition the request matched, or `null` when unsupported. |

**Returns**

`self`: View with the definition applied.

### withError() <span id="method-withError"></span>

```php
public function withError(string|null $error): self
```

Returns a copy carrying another routing failure.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$error` | `string\|null` | Routing failure reported while resolving the request, or `null` to clear it. |

**Returns**

`self`: View with the error applied.

### withMessage() <span id="method-withMessage"></span>

```php
public function withMessage(string|null $message): self
```

Returns a copy carrying another resolution summary.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$message` | `string\|null` | Resolution summary shown above the routing trace, or `null` to clear it. |

**Returns**

`self`: View with the message applied.

### withParameters() <span id="method-withParameters"></span>

```php
public function withParameters(array<array-key, mixed> $parameters): self
```

Returns a copy carrying another set of route parameters.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$parameters` | `array<array-key, mixed>` | Parameters bound to the resolved route. |

**Returns**

`self`: View with the parameters applied.

### withTrace() <span id="method-withTrace"></span>

```php
public function withTrace(list<PHPForge\Debug\Panel\Request\Routing\RouteTraceRow> $trace): self
```

Returns a copy carrying another routing trace.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$trace` | `list<`[`RouteTraceRow`](/docs/extensions/debug-core/reference/panel/request/routing/routetracerow/index.md)`>` | Routing rules inspected while resolving the request. |

**Returns**

`self`: View with the trace applied.