public function setExtension(string $extension)
    {
        $old = $this->getPath();
        $new = $this->getLocation().DIRECTORY_SEPARATOR.$this->getName();

        if(!empty($extension)) {
            $new .= ".{$extension}";
        }

        if(rename($old, $new)) {
            $this->_extension = $extension;
        }
    }
public function setExtension(string $extension)
    {
        $old = $this->getPath();
        $new = $this->getLocation().DIRECTORY_SEPARATOR.$this->getName();

        if(!empty($extension)) {
            $new .= ".{$extension}";
        }

        if(rename($old, $new)) {
            $this->_extension = $extension;
        }
    }
public function setExtension ( string $ extension ) { $ old = $ this -> getPath ( ) ; $ new = $ this -> getLocation ( ) . DIRECTORY_SEPARATOR . $ this -> getName ( ) ; if ( ! empty ( $ extension ) ) { $ new .= ".{$extension}" ; } if ( rename ( $ old , $ new ) ) { $ this -> _extension = $ extension ; } }
Renames file extension.

@param string $extension New file extension.
Renames file extension .