<?php

declare(strict_types=1);

namespace App\Handler\Api;

use App\Service\YearManager;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use UtilityModule\Handler\AbstractCrudHandler;
use Zend\Diactoros\Response\JsonResponse;

class YearsHandler extends AbstractCrudHandler
{
    /** @var YearManager */
    private $yearManager;

    public function __construct(
        YearManager $yearManager
    ) {
        $this->yearManager = $yearManager;
    }

    /**
     * @param ServerRequestInterface $request
     * @return ResponseInterface
     */
    public function getList(ServerRequestInterface $request) : ResponseInterface
    {
        $judges = $this->yearManager->getYears();
        return new JsonResponse($judges);
    }
}
