2023-06-22 07:36:22 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Classes\File;
|
|
|
|
|
|
|
|
use App\Classes\FTN\Tic as FTNTic;
|
|
|
|
use App\Models\{Address,File};
|
|
|
|
|
|
|
|
class Tic extends Item
|
|
|
|
{
|
2023-07-02 13:40:08 +00:00
|
|
|
private string $file;
|
|
|
|
|
2023-06-22 07:36:22 +00:00
|
|
|
/**
|
|
|
|
* @throws \Exception
|
|
|
|
*/
|
|
|
|
public function __construct(Address $ao,File $fo,int $action)
|
|
|
|
{
|
|
|
|
switch ($action) {
|
|
|
|
case self::I_SEND:
|
2023-07-02 13:40:08 +00:00
|
|
|
$tic = new FTNTic;
|
2023-06-22 07:36:22 +00:00
|
|
|
$this->file = $tic->generate($ao,$fo);
|
|
|
|
$this->file_name = sprintf('%s.tic',sprintf('%08x',$fo->id));
|
|
|
|
$this->file_size = strlen($this->file);
|
|
|
|
$this->file_mtime = $fo->created_at->timestamp;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
throw new \Exception('Unknown action: '.$action);
|
|
|
|
}
|
2023-07-02 13:40:08 +00:00
|
|
|
|
|
|
|
$this->action = $action;
|
|
|
|
$this->type = self::IS_TIC;
|
2023-06-22 07:36:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function read(int $start,int $length): string
|
|
|
|
{
|
|
|
|
return substr($this->file,$start,$length);
|
|
|
|
}
|
|
|
|
}
|