# JobRecord

> Typed view-model for a single queue lifecycle event captured during the request (push, exec, or error).

[API reference](/docs/api/index.md) › [Debug Core](/docs/extensions/debug-core/reference/index.md) › [Panel](/docs/extensions/debug-core/reference/panel/index.md) › [Queue](/docs/extensions/debug-core/reference/panel/queue/index.md) › JobRecord

| final readonly class | `PHPForge\Debug\Panel\Queue\JobRecord` |
| --- | --- |
| Implements | [`PHPForge\Debug\Storage\PanelRow`](/docs/extensions/debug-core/reference/storage/panelrow/index.md) |
| Source | [`src/Panel/Queue/JobRecord.php`](https://github.com/php-forge/debug-core/blob/main/src/Panel/Queue/JobRecord.php#L17) |

Typed view-model for a single queue lifecycle event captured during the request (push, exec, or error).

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-attempt"></span>`$attempt` readonly constructor | `int\|null` | Current attempt number for `exec` / `error` events (`1` for the first run). `null` for `push` events. | `JobRecord` |
| <span id="property-componentId"></span>`$componentId` readonly constructor | `string` | Identifier of the queue component that emitted the event (`'queue'`, `'queueEmail'`, ...). `''` when the sender could not be matched against any registered component. | `JobRecord` |
| <span id="property-delay"></span>`$delay` readonly constructor | `int\|null` | Delay before execution declared at push time, in seconds. `null` when the driver default applies. | `JobRecord` |
| <span id="property-driverClass"></span>`$driverClass` readonly constructor | `string` | Fully qualified class name of the queue driver that emitted the event. `''` when the sender was not an object (defensive default). | `JobRecord` |
| <span id="property-driverName"></span>`$driverName` readonly constructor | `string` | Friendly display name of the queue driver detected from the event sender's class name (`'Sync'`, `'Database'`, `'Redis'`, `'AMQP'`, `'Beanstalk'`, `'Gearman'`, or a custom-detected fallback). | `JobRecord` |
| <span id="property-duration"></span>`$duration` readonly constructor | `float\|null` | Execution time in seconds for `exec` / `error` events. `null` for `push` events. | `JobRecord` |
| <span id="property-error"></span>`$error` readonly constructor | `string` | Captured exception message for `error` events. `''` for `push` / `exec` events. | `JobRecord` |
| <span id="property-eventType"></span>`$eventType` readonly constructor | `string` | Lifecycle phase: `'push'` (job enqueued), `'exec'` (job finished successfully) or `'error'` (job threw). | `JobRecord` |
| <span id="property-isAsync"></span>`$isAsync` readonly constructor | `bool` | `false` when the driver runs jobs in-process during the same request (sync), `true` when jobs run in a separate worker (db, redis, amqp, beanstalk, gearman). The detail view uses this flag to show a hint about exec events living in CLI debug snapshots. | `JobRecord` |
| <span id="property-jobClass"></span>`$jobClass` readonly constructor | `string` | Fully qualified class name of the job. `''` when the event carried no job (defensive default). | `JobRecord` |
| <span id="property-jobId"></span>`$jobId` readonly constructor | `string` | Driver-specific message id (the queue's internal handle), or `''` when the driver did not expose one. | `JobRecord` |
| [`$payloadFields`](#property-payloadFields) readonly constructor | `array<string, mixed>` | Recursively normalised public-property tree of the job payload, captured at push time. | `JobRecord` |
| <span id="property-priority"></span>`$priority` readonly constructor | `int\|null` | Priority override declared at push time. `null` when the driver default applies. | `JobRecord` |
| <span id="property-time"></span>`$time` readonly constructor | `float` | Capture timestamp in seconds since the Unix epoch (microseconds preserved as the fractional part). | `JobRecord` |
| <span id="property-ttr"></span>`$ttr` readonly constructor | `int\|null` | Time-to-run override declared at push time, in seconds. `null` when the driver default applies. | `JobRecord` |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Creates a queue lifecycle event record. | `JobRecord` |
| [`fromArray()`](#method-fromArray) static | Narrows one persisted event of the queue payload into a typed record. | `JobRecord` |
| [`fromCapture()`](#method-fromCapture) static | Narrows one captured queue-event payload into a typed record. | `JobRecord` |
| [`jsonSerialize()`](#method-jsonSerialize) | Returns the typed row for JSON serialization. | `JobRecord` |

## Constants

| Constant | Value | Description | Defined by |
| --- | --- | --- | --- |
| <span id="const-EVENT_TYPES"></span>`EVENT_TYPES` | `[self::TYPE_PUSH, self::TYPE_EXEC, self::TYPE_ERROR]` |  | `JobRecord` |
| <span id="const-EVENT_VARIANTS"></span>`EVENT_VARIANTS` | `[self::TYPE_PUSH => ['variant' => 'queued', 'label' => 'Queued'], self::TYPE_EXEC => ['variant' => 'done', 'label' => 'Done'], self::TYPE_ERROR => ['variant' => 'failed', 'label' => 'Failed']]` |  | `JobRecord` |
| <span id="const-TYPE_ERROR"></span>`TYPE_ERROR` | `'error'` | Lifecycle phase value used when the job threw. | `JobRecord` |
| <span id="const-TYPE_EXEC"></span>`TYPE_EXEC` | `'exec'` | Lifecycle phase value used when the job finished successfully. | `JobRecord` |
| <span id="const-TYPE_PUSH"></span>`TYPE_PUSH` | `'push'` | Lifecycle phase value used when the job was enqueued. | `JobRecord` |

## Property details

### $payloadFields <span id="property-payloadFields"></span>

```php
public readonly array<string, mixed> $payloadFields
```

Recursively normalised public-property tree of the job payload, captured at push time.

Scalars (string/int/float/bool/null) round-trip as-is; nested objects expand into nested arrays
with a synthetic `__class` key carrying their FQCN. Empty when the event carried no job.

## Method details

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

```php
public function __construct(string $eventType, string $componentId, string $driverName, string $driverClass, bool $isAsync, string $jobClass, array $payloadFields, float $time, string $jobId, int|null $ttr, int|null $delay, int|null $priority, int|null $attempt, float|null $duration, string $error)
```

Creates a queue lifecycle event record.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$eventType` | `string` |  |
| `$componentId` | `string` |  |
| `$driverName` | `string` |  |
| `$driverClass` | `string` |  |
| `$isAsync` | `bool` |  |
| `$jobClass` | `string` |  |
| `$payloadFields` | `array` |  |
| `$time` | `float` |  |
| `$jobId` | `string` |  |
| `$ttr` | `int\|null` |  |
| `$delay` | `int\|null` |  |
| `$priority` | `int\|null` |  |
| `$attempt` | `int\|null` |  |
| `$duration` | `float\|null` |  |
| `$error` | `string` |  |

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

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

Narrows one persisted event of the queue payload into a typed record.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$data` | `mixed` | Persisted event, expected to be an object carrying the declared shape. |
| `$path` | `string` | JSON path of the event, used to report a malformed payload. |

**Returns**

`self`: Record carrying every persisted event field.

**Throws**

- [`PHPForge\Debug\Storage\HydrationException`](/docs/extensions/debug-core/reference/storage/hydrationexception/index.md): When the persisted event type is not one of [`JobRecord::EVENT_TYPES`](/docs/extensions/debug-core/reference/panel/queue/jobrecord/index.md#const-EVENT_TYPES).

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

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

Narrows one captured queue-event payload into a typed record.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$row` | `array<array-key, mixed>` | Captured payload. |

**Returns**

`self`

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

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

Returns the typed row for JSON serialization.

**Returns**

`array<string, mixed>`