public function replaceExtension($extension)
    {
        $atoms = $this->nameAtoms();
        if (array('', '') === $atoms) {
            if (null === $extension) {
                return $this;
            }

            return $this->replaceName(
                static::EXTENSION_SEPARATOR . $extension
            );
        }

        $numAtoms = count($atoms);

        if ($numAtoms > 1) {
            if (null === $extension) {
                $replacement = array();
            } else {
                $replacement = array($extension);
            }

            array_splice($atoms, -1, $numAtoms, $replacement);
        } elseif (null !== $extension) {
            $atoms[] = $extension;
        }

        return $this->replaceName(implode(self::EXTENSION_SEPARATOR, $atoms));
    }
public function replaceExtension($extension)
    {
        $atoms = $this->nameAtoms();
        if (array('', '') === $atoms) {
            if (null === $extension) {
                return $this;
            }

            return $this->replaceName(
                static::EXTENSION_SEPARATOR . $extension
            );
        }

        $numAtoms = count($atoms);

        if ($numAtoms > 1) {
            if (null === $extension) {
                $replacement = array();
            } else {
                $replacement = array($extension);
            }

            array_splice($atoms, -1, $numAtoms, $replacement);
        } elseif (null !== $extension) {
            $atoms[] = $extension;
        }

        return $this->replaceName(implode(self::EXTENSION_SEPARATOR, $atoms));
    }
public function replaceExtension ( $ extension ) { $ atoms = $ this -> nameAtoms ( ) ; if ( array ( '' , '' ) === $ atoms ) { if ( null === $ extension ) { return $ this ; } return $ this -> replaceName ( static :: EXTENSION_SEPARATOR . $ extension ) ; } $ numAtoms = count ( $ atoms ) ; if ( $ numAtoms > 1 ) { if ( null === $ extension ) { $ replacement = array ( ) ; } else { $ replacement = array ( $ extension ) ; } array_splice ( $ atoms , - 1 , $ numAtoms , $ replacement ) ; } elseif ( null !== $ extension ) { $ atoms [ ] = $ extension ; } return $ this -> replaceName ( implode ( self :: EXTENSION_SEPARATOR , $ atoms ) ) ; }
Replace this path's last extension.

@param string|null $extension The replacement string, or null to remove the last extension.

@return PathInterface A new path instance with the supplied extension replacing the existing one.
Replace this path s last extension .