public function copy($pathname)
    {
        if (!empty($pathname)) {
            if ($pathname instanceof \SplFileInfo) {
                $targetFile = $pathname;
            } else {
                $targetFile = new File($pathname);
            }

            if ($targetFile->isDir()) {
                $targetPathname = $targetFile->getPathname() . self::PATH_SEPARATOR . $this->getBasename();
                if ($this->isFile()) {
                    if (copy($this->getPathname(), $targetPathname)) {
                        parent::__construct($targetPathname);
                        return true;
                    }
                } elseif ($this->isDir()) {
                    if ($this->copyAction($this->getPathname(), $targetPathname, true)) {
                        parent::__construct($targetPathname);
                        return true;
                    }
                } else {
                    throw new FileException('Copy failed, source file or directory do not exist.');
                }
            } else {
                throw new FileException('Copy failed, target directory do not exist.');
            }
        } else {
            throw new FileException('Copy failed, because given filepath is empty.');
        }
        return false;
    }
public function copy($pathname)
    {
        if (!empty($pathname)) {
            if ($pathname instanceof \SplFileInfo) {
                $targetFile = $pathname;
            } else {
                $targetFile = new File($pathname);
            }

            if ($targetFile->isDir()) {
                $targetPathname = $targetFile->getPathname() . self::PATH_SEPARATOR . $this->getBasename();
                if ($this->isFile()) {
                    if (copy($this->getPathname(), $targetPathname)) {
                        parent::__construct($targetPathname);
                        return true;
                    }
                } elseif ($this->isDir()) {
                    if ($this->copyAction($this->getPathname(), $targetPathname, true)) {
                        parent::__construct($targetPathname);
                        return true;
                    }
                } else {
                    throw new FileException('Copy failed, source file or directory do not exist.');
                }
            } else {
                throw new FileException('Copy failed, target directory do not exist.');
            }
        } else {
            throw new FileException('Copy failed, because given filepath is empty.');
        }
        return false;
    }
public function copy ( $ pathname ) { if ( ! empty ( $ pathname ) ) { if ( $ pathname instanceof \ SplFileInfo ) { $ targetFile = $ pathname ; } else { $ targetFile = new File ( $ pathname ) ; } if ( $ targetFile -> isDir ( ) ) { $ targetPathname = $ targetFile -> getPathname ( ) . self :: PATH_SEPARATOR . $ this -> getBasename ( ) ; if ( $ this -> isFile ( ) ) { if ( copy ( $ this -> getPathname ( ) , $ targetPathname ) ) { parent :: __construct ( $ targetPathname ) ; return true ; } } elseif ( $ this -> isDir ( ) ) { if ( $ this -> copyAction ( $ this -> getPathname ( ) , $ targetPathname , true ) ) { parent :: __construct ( $ targetPathname ) ; return true ; } } else { throw new FileException ( 'Copy failed, source file or directory do not exist.' ) ; } } else { throw new FileException ( 'Copy failed, target directory do not exist.' ) ; } } else { throw new FileException ( 'Copy failed, because given filepath is empty.' ) ; } return false ; }
copy file to a given directory

@param       \SplFileInfo|string        $pathname
@return      bool
@throws      FileException
copy file to a given directory