<?php

declare(strict_types=1);

namespace App\Administration\Infrastructure\Storage;

use App\Administration\Application\Port\LogoStorage;

use function count;

use Override;

final class InMemoryLogoStorage implements LogoStorage
{
    /** @var array<string, array{content: string, contentType: string}> */
    private array $files = [];

    #[Override]
    public function store(string $content, string $key, string $contentType): string
    {
        $this->files[$key] = ['content' => $content, 'contentType' => $contentType];

        return 'https://storage.example.com/' . $key;
    }

    #[Override]
    public function delete(string $key): void
    {
        unset($this->files[$key]);
    }

    public function has(string $key): bool
    {
        return isset($this->files[$key]);
    }

    public function count(): int
    {
        return count($this->files);
    }
}
