<?php

namespace ZenoChatbot\Services\LLMService\AIClient\Results;

if (!defined('ABSPATH')) {
    exit;
}

class TokenUsage
{
    private int $promptTokens;
    private int $completionTokens;
    private int $totalTokens;

    public function __construct(int $promptTokens = 0, int $completionTokens = 0, int $totalTokens = 0)
    {
        $this->promptTokens = $promptTokens;
        $this->completionTokens = $completionTokens;
        $this->totalTokens = $totalTokens ?: ($promptTokens + $completionTokens);
    }

    public function getPromptTokens(): int
    {
        return $this->promptTokens;
    }

    public function getCompletionTokens(): int
    {
        return $this->completionTokens;
    }

    public function getTotalTokens(): int
    {
        return $this->totalTokens;
    }

    public function toArray(): array
    {
        return [
            'prompt_tokens'     => $this->promptTokens,
            'completion_tokens' => $this->completionTokens,
            'total_tokens'      => $this->totalTokens,
        ];
    }
}

