<?php

declare(strict_types=1);

namespace App\Controllers;

use App\Core\Controller;
use App\Models\DemoData;
use App\Services\QrCodeService;

final class QrController extends Controller
{
    public function index(): string
    {
        $qr = new QrCodeService();
        $links = array_map(static function (array $link) use ($qr): array {
            $link['qr'] = $qr->dataUri($link['url']);

            return $link;
        }, DemoData::qrLinks());

        return $this->view('qr/index', [
            'title' => 'QR библиотека',
            'links' => $links,
        ]);
    }
}
