file = $mail; break; default: throw new \Exception('Unknown action: '.$action); } $this->action = $action; } public function __get($key) { switch ($key) { case 'file': return $this->file; default: return parent::__get($key); } } public function read(int $start,int $length): string { return substr((string)$this->file,$start,$length); } public function youngest(): Carbon { return $this->file->messages->pluck('date')->sort()->last(); } }