<?php

declare(strict_types=1);

namespace App\Framework\DateTime;

use App\Framework\Config\AppConfig;
use App\Framework\DI\Initializer;
use DateTimeZone;

final readonly class ClockInitializer
{
    public function __construct(
        private AppConfig $config
    ) {}

    #[Initializer]
    public function __invoke(): Clock
    {
        $timezone = $this->config->timezone;

        $timezone = new DateTimeZone($timezone->value);

        return new SystemClock($timezone);
    }

    #[Initializer]
    public function initTimer(): Timer
    {
        return new SystemTimer();
    }
}
