<?php
declare(strict_types=1);
namespace Controllers;

use Helpers\Request;
use Helpers\Response;
use Services\ProductService;

final class ProductController
{
    private ProductService $service;
    public function __construct() { $this->service = new ProductService(); }
    public function index(): never { Response::success($this->service->list(Request::query())); }
    public function show(string $slug): never
    {
        $product = $this->service->detail($slug);
        if (!$product) Response::error('Product not found', 404);
        Response::success($product);
    }
}
