<?php

namespace App\Services\ClassProgress;

use App\Models\SubjectCurriculum;

class ClassProgressMetaService
{
    public function subjectSections(): array
    {
        return (array) config('progress.subject_sections', []);
    }

    public function statusOptions(): array
    {
        return (array) config('progress.status_options', []);
    }

    public function sundayOptions(int $count = 12): array
    {
        $start = now();
        if ((int) $start->format('w') !== 0) {
            $start = $start->next('Sunday');
        }

        $options = [];
        for ($i = 0; $i < $count; $i++) {
            $options[] = $start->format('Y-m-d');
            $start = $start->addDays(7);
        }

        return $options;
    }

    public function curriculumOptions(?int $classId): array
    {
        if (!$classId) {
            return [];
        }

        $options = [];
        foreach ($this->subjectSections() as $slug => $section) {
            $options[$slug] = SubjectCurriculum::getOptionsForClass((int) $classId, (string) $slug);
        }

        return $options;
    }
}
