<?php

namespace App\Domain\Scraping\Domain\Model\ValueObject;

readonly class ImageUrl
{
    public function __construct(
        private string $url
    ) {
        if (!filter_var($url, FILTER_VALIDATE_URL)) {
            throw new \InvalidArgumentException('Invalid image URL provided');
        }
    }

    public function getValue(): string
    {
        return $this->url;
    }

    public function getExtension(): string
    {
        return pathinfo(parse_url($this->url, PHP_URL_PATH), PATHINFO_EXTENSION);
    }
}
