payload ?? '', true) ?: []; $command = $payload['data']['command'] ?? null; unset($payload['data']['command']); return [ 'id' => $job->id, 'name' => $payload['displayName'] ?? $job->name ?? null, 'connection' => $job->connection ?? null, 'queue' => $job->queue ?? null, 'status' => $job->status ?? null, 'attempts' => $payload['attempts'] ?? 0, 'max_tries' => $payload['maxTries'] ?? null, 'timeout' => $payload['timeout'] ?? null, 'tags' => $payload['tags'] ?? [], 'pushed_at' => self::iso($payload['pushedAt'] ?? null), 'reserved_at' => self::iso($job->reserved_at ?? null), 'completed_at' => self::iso($job->completed_at ?? null), 'failed_at' => self::iso($job->failed_at ?? null), 'retried_by' => json_decode($job->retried_by ?? '[]', true) ?: [], 'properties' => is_string($command) ? self::properties($command) : [], 'exception' => $job->exception ?? null, 'context' => json_decode($job->context ?? 'null', true), 'payload' => $payload, ]; } private static function properties(string $serialized): array { preg_match_all( '/s:\d+:"(?:\x00[^\x00]*\x00)?(\w+)";(?:i:(-?\d+)|d:([-\d.eE+]+)|b:([01])|s:\d+:"(.*?)"|N);/s', $serialized, $matches, PREG_SET_ORDER ); $properties = []; foreach ($matches as $m) { $name = $m[1]; $value = match (true) { ($m[2] ?? '') !== '' => (int) $m[2], ($m[3] ?? '') !== '' => (float) $m[3], ($m[4] ?? '') !== '' => $m[4] === '1', array_key_exists(5, $m) && $m[5] !== '' => $m[5], default => null, }; $properties[$name] = preg_match(self::SENSITIVE, $name) && $value !== null ? '********' : $value; } return $properties; } private static function iso(int|float|string|null $ts): ?string { return $ts ? \Carbon\Carbon::createFromTimestamp((int) $ts)->toIso8601String() : null; } }