src/php/Webforge/Common/System/File.php
public function copy($destination) {
    
    if (!$this->exists()) {
      throw new Exception('Source from copy does not exist: '.$this);
    }
    
    if ($destination instanceof Dir) {
      $destination = $destination->getFile($this->getName());
    } elseif (!($destination instanceof File)) {
      throw new InvalidArgumentException('Invalid Argument. $destination must be file or dir');
    }

    if (!$destination->getDirectory()->exists()) {
      throw new Exception('The directory from the destination file does not exist: '.$destination);
    }

    $ret = @copy((string) $this, (string) $destination);

    if (!$ret) {
      throw new Exception('PHP Error while copying '.$this.' onto '.$destination);
    }
    
    return $this;
  }
public function copy($destination) {
    
    if (!$this->exists()) {
      throw new Exception('Source from copy does not exist: '.$this);
    }
    
    if ($destination instanceof Dir) {
      $destination = $destination->getFile($this->getName());
    } elseif (!($destination instanceof File)) {
      throw new InvalidArgumentException('Invalid Argument. $destination must be file or dir');
    }

    if (!$destination->getDirectory()->exists()) {
      throw new Exception('The directory from the destination file does not exist: '.$destination);
    }

    $ret = @copy((string) $this, (string) $destination);

    if (!$ret) {
      throw new Exception('PHP Error while copying '.$this.' onto '.$destination);
    }
    
    return $this;
  }
public function copy ( $ destination ) { if ( ! $ this -> exists ( ) ) { throw new Exception ( 'Source from copy does not exist: ' . $ this ) ; } if ( $ destination instanceof Dir ) { $ destination = $ destination -> getFile ( $ this -> getName ( ) ) ; } elseif ( ! ( $ destination instanceof File ) ) { throw new InvalidArgumentException ( 'Invalid Argument. $destination must be file or dir' ) ; } if ( ! $ destination -> getDirectory ( ) -> exists ( ) ) { throw new Exception ( 'The directory from the destination file does not exist: ' . $ destination ) ; } $ ret = @ copy ( ( string ) $ this , ( string ) $ destination ) ; if ( ! $ ret ) { throw new Exception ( 'PHP Error while copying ' . $ this . ' onto ' . $ destination ) ; } return $ this ; }
Copys the file to another file or into an directory

@param File|Dir $fileDestination
@chainable
Copys the file to another file or into an directory