<?php

declare(strict_types=1);

namespace PhpWA\Media;

use InvalidArgumentException;

final class MediaUploadResult
{
      private $encrypted;
      private $url;
      private $directPath;
    public function __construct(EncryptedMedia $encrypted, string $url, string $directPath)
    {
        $parts = parse_url($url);
        if (!is_array($parts) || ($parts['scheme'] ?? null) !== 'https' || !isset($parts['host'])
            || $directPath === '' || strlen($directPath) > 8192 || $directPath[0] !== '/' || preg_match('/[\x00-\x1f\x7f]/', $directPath) === 1) {
            throw new InvalidArgumentException('Media upload response is invalid.');
        }
        $this->encrypted = $encrypted; $this->url = $url; $this->directPath = $directPath;
    }
    public function encrypted(): EncryptedMedia { return $this->encrypted; }
    public function url(): string { return $this->url; }
    public function directPath(): string { return $this->directPath; }
}
