action |= $action; switch ($action) { case self::I_SEND: $this->file = $mail; $this->file_name = sprintf('%08x.pkt',Carbon::now()->timestamp); $this->file_size = strlen($mail); $this->file_mtime = Carbon::now()->timestamp; // @todo This timestamp should be consistent incase of retries break; default: throw new \Exception('Unknown action: '.$action); } } public function read(int $start,int $length): string { return substr((string)$this->file,$start,$length); } }