$buckets */ public function __construct( public readonly string $requestId, public readonly array $buckets, public readonly int $reservedUnits, public readonly ?int $settledUnits, public readonly string $state, public readonly ?string $note, public readonly bool $duplicate = false, public readonly ?string $usageBasis = null, public readonly ?int $estimateUnits = null, public readonly ?string $origin = null, public readonly ?int $botId = null, public readonly ?int $connectionId = null, public readonly ?string $requestModel = null, public readonly ?int $providerInputTokens = null, public readonly ?int $providerOutputTokens = null, public readonly ?string $provider = null, public readonly ?string $servedModel = null, public readonly ?int $cachedInputTokens = null, public readonly ?int $reasoningTokens = null, public readonly ?int $otherTokens = null, public readonly ?string $processingTier = null, ) { } /** @param array $row */ public static function fromRow(array $row): self { return new self( (string) $row['request_id'], json_decode((string) $row['buckets'], true, 4, JSON_THROW_ON_ERROR), (int) $row['reserved_units'], $row['settled_units'] === null ? null : (int) $row['settled_units'], (string) $row['state'], $row['note'] === null ? null : (string) $row['note'], false, isset($row['usage_basis']) ? (string) $row['usage_basis'] : null, isset($row['estimate_units']) ? (int) $row['estimate_units'] : null, isset($row['origin']) ? (string) $row['origin'] : null, isset($row['bot_id']) ? (int) $row['bot_id'] : null, isset($row['connection_id']) ? (int) $row['connection_id'] : null, isset($row['request_model']) ? (string) $row['request_model'] : null, isset($row['provider_input_tokens']) ? (int) $row['provider_input_tokens'] : null, isset($row['provider_output_tokens']) ? (int) $row['provider_output_tokens'] : null, isset($row['provider']) ? (string) $row['provider'] : null, isset($row['served_model']) ? (string) $row['served_model'] : null, isset($row['provider_cached_input_tokens']) ? (int) $row['provider_cached_input_tokens'] : null, isset($row['provider_reasoning_tokens']) ? (int) $row['provider_reasoning_tokens'] : null, isset($row['provider_other_tokens']) ? (int) $row['provider_other_tokens'] : null, isset($row['processing_tier']) ? (string) $row['processing_tier'] : null, ); } public function asDuplicate(): self { return new self($this->requestId, $this->buckets, $this->reservedUnits, $this->settledUnits, $this->state, $this->note, true, $this->usageBasis, $this->estimateUnits, $this->origin, $this->botId, $this->connectionId, $this->requestModel, $this->providerInputTokens, $this->providerOutputTokens, $this->provider, $this->servedModel, $this->cachedInputTokens, $this->reasoningTokens, $this->otherTokens, $this->processingTier); } }