<?php

use MintyPHP\Service\Branding\BrandingServicesFactory;

define('MINTY_ALLOW_OUTPUT', true);

$size = isset($_GET['size']) ? (int) $_GET['size'] : null;
$logoService = app(\MintyPHP\Service\Branding\BrandingLogoService::class);
$path = $logoService->findLogoPath($size);
if (!$path || !is_file($path)) {
    http_response_code(404);
    return;
}

$mime = $logoService->detectMime($path);
header('Content-Type: ' . $mime);
header('X-Content-Type-Options: nosniff');
header("Content-Security-Policy: sandbox");
header('Cache-Control: public, max-age=86400');
header('Content-Length: ' . filesize($path));
readfile($path);
return;
