# RequestSnapshot

> Canonical Request panel snapshot.

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

| final readonly class | `PHPForge\Debug\Panel\Request\RequestSnapshot` |
| --- | --- |
| Implements | [`PHPForge\Debug\Storage\PanelSnapshot`](/docs/extensions/debug-core/reference/storage/panelsnapshot/index.md) |
| Source | [`src/Panel/Request/RequestSnapshot.php`](https://github.com/php-forge/debug-core/blob/main/src/Panel/Request/RequestSnapshot.php#L14) |

Canonical Request panel snapshot.

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-statusCode"></span>`$statusCode` readonly constructor | `int` | HTTP status code the request completed with. | `RequestSnapshot` |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`capture()`](#method-capture) static | Captures the Request payload together with the status code it must agree with. | `RequestSnapshot` |
| [`data()`](#method-data) | Returns the payload restored to plain PHP values. | `RequestSnapshot` |
| [`fromArray()`](#method-fromArray) static | Hydrates the Request panel snapshot from decoded JSON data. | `RequestSnapshot` |
| [`jsonSerialize()`](#method-jsonSerialize) | Returns the snapshot for JSON serialization. | `RequestSnapshot` |

## Method details

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

```php
public static function capture(array<array-key, mixed> $data): self
```

Captures the Request payload together with the status code it must agree with.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$data` | `array<array-key, mixed>` | Raw Request payload captured for the request. |

**Returns**

`self`: Snapshot carrying the tagged payload and its status code.

**Throws**

- [`PHPForge\Debug\Storage\HydrationException`](/docs/extensions/debug-core/reference/storage/hydrationexception/index.md): When the payload carries no integer `statusCode`.

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

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

Returns the payload restored to plain PHP values.

**Returns**

`array<array-key, mixed>`: Payload restored to plain PHP values.

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

```php
public static function fromArray(mixed $data, string $path): self
```

Hydrates the Request panel snapshot from decoded JSON data.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$data` | `mixed` | Decoded Request panel payload. |
| `$path` | `string` | Payload path used in hydration errors. |

**Returns**

`self`: Hydrated Request panel snapshot.

**Throws**

- [`PHPForge\Debug\Storage\HydrationException`](/docs/extensions/debug-core/reference/storage/hydrationexception/index.md): When the stored status code disagrees with the one held in the payload.

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

```php
public function jsonSerialize(): array<string, mixed>
```

Returns the snapshot for JSON serialization.

**Returns**

`array<string, mixed>`: Tagged payload and the status code it agrees with.