file = new splFileInfo($path); if (!$this->file->isFile()) { throw new FileNotFoundException( sprintf('Attachment File not found "%s".', $path) ); } $this->name = $name === null ? $this->file->getFilename() : $name; $this->encoding = $encoding; $this->type = $type; $this->disposition = $disposition; } /** * @return string */ public function getPath():string { return $this->file->getRealPath(); } /** * @return string */ public function getName():string { return $this->name; } /** * @return string */ public function getEncoding():string { return $this->encoding; } /** * @return string */ public function getType():string { return $this->type; } /** * @return string */ public function getDisposition(): string { return $this->disposition; } /** * @return string */ public function __toString():string { return (string)$this->file; } }