<?php

declare(strict_types=1);

namespace App\Application\Website;

use App\Framework\Attributes\Route;

final readonly class ShowVcard
{
    #[Route('/kontakt.vcf')]
    public function __invoke(): void
    {
        // Kontaktdaten
        $name = "Michael";
        $nachname = "Schiemer";
        $telefon = "+49 123 456789";
        $email = "konakt@michaelschiemer.de";

        // vCard-Text zusammenbauen
        $vcf = "BEGIN:VCARD\r\n";
        $vcf .= "VERSION:3.0\r\n";
        $vcf .= "N:$nachname;$name;;;\r\n";
        $vcf .= "FN:$name $nachname\r\n";
        $vcf .= "TEL;TYPE=CELL,VOICE:$telefon\r\n";
        $vcf .= "EMAIL;TYPE=INTERNET:$email\r\n";
        $vcf .= "END:VCARD\r\n";

        // Datei speichern

        // Oder zum Download anbieten
        header('Content-Type: text/vcard; charset=utf-8');
        header('Content-Disposition: attachment; filename="kontakt.vcf"');
        echo $vcf;
        exit;
    }
}
