<?php

namespace Openguru\OpenCartFramework\Scheduler;

class SchedulerResult
{
    public array $executed = [];
    public array $failed = [];
    public array $skipped = [];

    public function addExecuted(string $name, float $duration): void
    {
        $this->executed[] = [
            'name' => $name,
            'duration' => $duration,
        ];
    }

    public function addFailed(string $name, string $error): void
    {
        $this->failed[] = [
            'name' => $name,
            'error' => $error,
        ];
    }

    public function addSkipped(string $name, string $reason): void
    {
        $this->skipped[] = [
            'name' => $name,
            'reason' => $reason,
        ];
    }

    public function toArray(): array
    {
        return [
            'executed' => $this->executed,
            'failed' => $this->failed,
            'skipped' => $this->skipped,
        ];
    }
}
