# RequestHero

> Immutable Request identity with optional response, timing, and display metadata.

[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) › RequestHero

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

Immutable Request identity with optional response, timing, and display metadata.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Creates a request identity ready for response and display metadata. | `RequestHero` |
| [`create()`](#method-create) static | Creates a hero carrying the request identity, ready for immutable enrichment. | `RequestHero` |
| [`getDurationMs()`](#method-getDurationMs) | Returns the processing time of the request. | `RequestHero` |
| [`getFlags()`](#method-getFlags) | Returns the flags shown on the meta strip. | `RequestHero` |
| [`getIp()`](#method-getIp) | Returns the client address of the request. | `RequestHero` |
| [`getMethod()`](#method-getMethod) | Returns the HTTP method of the request. | `RequestHero` |
| [`getStatusCode()`](#method-getStatusCode) | Returns the response status code. | `RequestHero` |
| [`getStatusVariant()`](#method-getStatusVariant) | Returns the status-pill modifier of the response. | `RequestHero` |
| [`getTime()`](#method-getTime) | Returns the wall-clock time of the request. | `RequestHero` |
| [`getUrl()`](#method-getUrl) | Returns the full URL of the request. | `RequestHero` |
| [`withFlags()`](#method-withFlags) | Returns a copy carrying another set of flags. | `RequestHero` |
| [`withIp()`](#method-withIp) | Returns a copy carrying the client address. | `RequestHero` |
| [`withStatus()`](#method-withStatus) | Returns a copy carrying the captured response status. | `RequestHero` |
| [`withTiming()`](#method-withTiming) | Returns a copy carrying the captured timing. | `RequestHero` |

## Method details

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

```php
public function __construct(string $method, string $url)
```

Creates a request identity ready for response and display metadata.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$method` | `string` | HTTP method of the request. |
| `$url` | `string` | Full URL of the request. |

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

```php
public static function create(string $method, string $url): self
```

Creates a hero carrying the request identity, ready for immutable enrichment.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$method` | `string` | HTTP method of the request. |
| `$url` | `string` | Full URL of the request. |

**Returns**

`self`: Hero carrying only the request identity.

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

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

Returns the processing time of the request.

**Returns**

`string`: Formatted processing time, in milliseconds; empty when it was not captured.

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

```php
public function getFlags(): list<string>
```

Returns the flags shown on the meta strip.

**Returns**

`list<string>`: Boolean flags surfaced as chips on the meta strip, in display order.

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

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

Returns the client address of the request.

**Returns**

`string`: Client address of the request; empty when it was not captured.

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

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

Returns the HTTP method of the request.

**Returns**

`string`: HTTP method of the request.

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

```php
public function getStatusCode(): int
```

Returns the response status code.

**Returns**

`int`: Response status code; `0` when no response was captured.

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

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

Returns the status-pill modifier of the response.

**Returns**

`string`: Status-pill CSS modifier derived from the status code: `'2xx'` to `'5xx'`, or `'none'` when uncaptured.

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

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

Returns the wall-clock time of the request.

**Returns**

`string`: Formatted wall-clock time of the request; empty when it was not captured.

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

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

Returns the full URL of the request.

**Returns**

`string`: Full URL of the request.

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

```php
public function withFlags(list<string> $flags): self
```

Returns a copy carrying another set of flags.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$flags` | `list<string>` | Boolean flags surfaced as chips on the meta strip, in display order. |

**Returns**

`self`: Hero with the flags applied.

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

```php
public function withIp(string $ip): self
```

Returns a copy carrying the client address.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$ip` | `string` | Client address of the request; empty when it was not captured. |

**Returns**

`self`: Hero with the address applied.

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

```php
public function withStatus(int $statusCode, string $statusVariant): self
```

Returns a copy carrying the captured response status.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$statusCode` | `int` | Response status code; `0` when no response was captured. |
| `$statusVariant` | `string` | Status-pill CSS modifier derived from the status code: `'2xx'` to `'5xx'`, or `'none'` when uncaptured. |

**Returns**

`self`: Hero with the status applied.

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

```php
public function withTiming(string $time, string $durationMs): self
```

Returns a copy carrying the captured timing.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$time` | `string` | Formatted wall-clock time of the request; empty when it was not captured. |
| `$durationMs` | `string` | Formatted processing time, in milliseconds; empty when it was not captured. |

**Returns**

`self`: Hero with the timing applied.