D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
tattooscyy
/
test
/
app
/
Libs
/
Sdk
/
Domain
/
Filename :
UploadableFile.php
back
Copy
<?php namespace App\Libs\Sdk\Domain; use UnexpectedValueException; /** * Class UploadableFile * * @package OnlinePayments\Sdk\Domain */ class UploadableFile { /** @var string */ private string $fileName; /** @var resource|string|callable */ private $content; /** @var string */ private string $contentType; /** @var int */ private int $contentLength; /** * @param string $fileName * @param resource|string|callable $content * If it's a callable it should take a length argument and return a string that is not larger than the input. * @param string $contentType * @param int $contentLength */ public function __construct(string $fileName, $content, string $contentType, int $contentLength = -1) { if (strlen(trim($fileName)) == 0) { throw new UnexpectedValueException("fileName is required"); } if (!is_resource($content) && !is_string($content) && !is_callable($content)) { throw new UnexpectedValueException('content is required as resource, string or callable'); } if (strlen(trim($contentType)) == 0) { throw new UnexpectedValueException("contentType is required"); } $this->fileName = $fileName; $this->content = $content; $this->contentType = $contentType; $this->contentLength = max($contentLength, -1); if ($this->contentLength == -1 && is_string($content)) { $this->contentLength = strlen($content); } } /** * @return string The name of the file. */ public function getFileName(): string { return $this->fileName; } /** * @return resource|string|callable A resource, string or callable with the file's content. * If it's a callable it should take a length argument and return a string that is not larger than the input. */ public function getContent() { return $this->content; } /** * @return string The file's content type. */ public function getContentType(): string { return $this->contentType; } /** * @return int The file's content length, or -1 if not known. */ public function getContentLength(): int { return $this->contentLength; } }