42 lines
794 B
PHP
42 lines
794 B
PHP
<?php
|
|
|
|
namespace App\Media;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
abstract class Base
|
|
{
|
|
protected const BLOCK_SIZE = 4096;
|
|
|
|
/** Full path to the file */
|
|
protected string $filename;
|
|
protected int $filesize;
|
|
protected string $type;
|
|
|
|
public function __construct(string $filename,string $type)
|
|
{
|
|
Log::info(sprintf('Create a media type [%s] for [%s]',get_class($this),$filename));
|
|
|
|
$this->filename = $filename;
|
|
$this->filesize = filesize($filename);
|
|
$this->type = $type;
|
|
}
|
|
|
|
/**
|
|
* Enable getting values for keys in the response
|
|
*
|
|
* @param string $key
|
|
* @return mixed|object
|
|
* @throws \Exception
|
|
*/
|
|
public function __get(string $key): mixed
|
|
{
|
|
switch ($key) {
|
|
case 'type':
|
|
return $this->type;
|
|
|
|
default:
|
|
throw new \Exception('Unknown key: '.$key);
|
|
}
|
|
}
|
|
} |