# ArrayPayloadSnapshot

> Provides the capture/hydrate/serialize cycle for panels whose payload stays genuinely dynamic (application configuration, dumped values, and user-configured request globals).

[API reference](/docs/api/index.md) › [Debug Core](/docs/extensions/debug-core/reference/index.md) › [Storage](/docs/extensions/debug-core/reference/storage/index.md) › ArrayPayloadSnapshot

| trait | `PHPForge\Debug\Storage\ArrayPayloadSnapshot` |
| --- | --- |
| Source | [`src/Storage/ArrayPayloadSnapshot.php`](https://github.com/php-forge/debug-core/blob/main/src/Storage/ArrayPayloadSnapshot.php#L11) |

Used by 2 types:

- [`PHPForge\Debug\Panel\Config\ConfigSnapshot`](/docs/extensions/debug-core/reference/panel/config/configsnapshot/index.md)
- [`PHPForge\Debug\Panel\User\UserSnapshot`](/docs/extensions/debug-core/reference/panel/user/usersnapshot/index.md)

Provides the capture/hydrate/serialize cycle for panels whose payload stays genuinely dynamic (application
configuration, dumped values, and user-configured request globals).

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) final | Creates a snapshot from a tagged dynamic payload. | `ArrayPayloadSnapshot` |
| [`capture()`](#method-capture) static | Captures arbitrary array values in a JSON-safe snapshot. | `ArrayPayloadSnapshot` |
| [`fromArray()`](#method-fromArray) static | Hydrates a dynamic payload from decoded JSON data. | `ArrayPayloadSnapshot` |
| [`jsonSerialize()`](#method-jsonSerialize) | Returns the tagged payload for JSON serialization. | `ArrayPayloadSnapshot` |
| [`payloadKey()`](#method-payloadKey) protected static abstract | Returns the JSON key used to persist the dynamic payload. | `ArrayPayloadSnapshot` |

## Method details

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

```php
final public function __construct(PHPForge\Debug\Storage\DebugArray $payload)
```

Creates a snapshot from a tagged dynamic payload.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$payload` | [`DebugArray`](/docs/extensions/debug-core/reference/storage/debugarray/index.md) | Tagged dynamic payload. |

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

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

Captures arbitrary array values in a JSON-safe snapshot.

**Parameters**

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

**Returns**

`self`: Snapshot containing tagged debug values.

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

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

Hydrates a dynamic payload from decoded JSON data.

**Parameters**

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

**Returns**

`self`: Hydrated dynamic payload snapshot.

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

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

Returns the tagged payload for JSON serialization.

**Returns**

`array<string, mixed>`: Tagged payload indexed by its persistence key.

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

```php
abstract protected static function payloadKey(): string
```

Returns the JSON key used to persist the dynamic payload.

**Returns**

`string`: Persisted payload key.