public function __construct(FileObject $file, $name = null) { if (($file->exists() and $contents = $file->getContents()) === false or empty($contents)) { throw new InvalidArgumentException('EMA-006: The file does not exists, not readable or empty.'); } if ($name === null) { $name = pathinfo($file->getPath(), PATHINFO_BASENAME); } $this->file = $file; parent::__construct($name, $contents, $file->getMime()); }
/** * Adds an attachment * * @param Attachment $attachment * * @return this * * @since 2.0 */ public function attach(Attachment $attachment) { $this->attachments[] = $attachment; if ($attachment->isInline()) { $this->hasInline = true; } return $this; }