Пример #1
0
 /**
  * @param \SplFileInfo|FileInterface $file
  * @throws \InvalidArgumentException
  */
 public function copyContentFromFile($file)
 {
     if ($file instanceof \SplFileInfo) {
         $this->setFileContentFromFilesystem($file->getPathname());
     } elseif ($file instanceof BinaryInterface) {
         $this->setContentFromStream($file->getContentAsStream());
     } elseif ($file instanceof FileSystemInterface) {
         $this->setFileContentFromFilesystem($file->getFileSystemPath());
     } elseif ($file instanceof FileInterface) {
         $this->setContentFromString($file->getContentAsString());
     } else {
         $type = is_object($file) ? get_class($file) : gettype($file);
         throw new \InvalidArgumentException(sprintf('File is not a valid type, "%s" given.', $type));
     }
 }