src/File.php
public function extension($extension = false)
    {
        if($extension === false) {
            return $this->adapter->extension($this->path);
        }

        $newName = $this->name();
        $index = strrpos($newName, '.');
        if ($index !== false) {
            $newName = substr($newName, 0, $index + 1);
        } else {
            $newName .= '.';
        }
        $newName .= $extension;

        return $this->name($newName);
    }
public function extension($extension = false)
    {
        if($extension === false) {
            return $this->adapter->extension($this->path);
        }

        $newName = $this->name();
        $index = strrpos($newName, '.');
        if ($index !== false) {
            $newName = substr($newName, 0, $index + 1);
        } else {
            $newName .= '.';
        }
        $newName .= $extension;

        return $this->name($newName);
    }
public function extension ( $ extension = false ) { if ( $ extension === false ) { return $ this -> adapter -> extension ( $ this -> path ) ; } $ newName = $ this -> name ( ) ; $ index = strrpos ( $ newName , '.' ) ; if ( $ index !== false ) { $ newName = substr ( $ newName , 0 , $ index + 1 ) ; } else { $ newName .= '.' ; } $ newName .= $ extension ; return $ this -> name ( $ newName ) ; }
Gets or sets the file extension.

@param  string $extension
@return string|self
Gets or sets the file extension .