Kohana_Twig::set_extension PHP Method

set_extension() public method

Sets a file exension
Author: Jonathan Geiger
public set_extension ( string $extension ) : void
$extension string
return void
    public function set_extension($extension)
    {
        // Strip any leading period
        $extension = ltrim($extension, '.');
        // Use this for regenerating the path, using substr
        // or some other method seems like it could miss some edge-cases
        $pathinfo = pathinfo($this->_file);
        if (isset($pathinfo['dirname']) && isset($pathinfo['filename'])) {
            // Chomp off any extension at the end
            $this->_file = $pathinfo['dirname'] . '/' . $pathinfo['filename'];
        }
        // Save this for later
        $this->_extension = $extension;
        return $this;
    }