protected static function getUniqueFilePath( $startingPath = '' ) {
        if ( file_exists( $startingPath ) ) {
            $filename_ext = pathinfo( $startingPath, PATHINFO_EXTENSION );
            $startingPath = preg_replace( '/^(.*)\.' . $filename_ext . '$/', '$1_' . date( 'YmdHis' ) . '.' . $filename_ext, $startingPath );

            if ( is_null( $startingPath ) ) {
                throw new \Exception( "The php function preg_replace (called in Excel::getUniqueFilePath()) returned null, indicating an error." );
            }
        }

        return $startingPath;
    }
protected static function getUniqueFilePath( $startingPath = '' ) {
        if ( file_exists( $startingPath ) ) {
            $filename_ext = pathinfo( $startingPath, PATHINFO_EXTENSION );
            $startingPath = preg_replace( '/^(.*)\.' . $filename_ext . '$/', '$1_' . date( 'YmdHis' ) . '.' . $filename_ext, $startingPath );

            if ( is_null( $startingPath ) ) {
                throw new \Exception( "The php function preg_replace (called in Excel::getUniqueFilePath()) returned null, indicating an error." );
            }
        }

        return $startingPath;
    }
protected static function getUniqueFilePath ( $ startingPath = '' ) { if ( file_exists ( $ startingPath ) ) { $ filename_ext = pathinfo ( $ startingPath , PATHINFO_EXTENSION ) ; $ startingPath = preg_replace ( '/^(.*)\.' . $ filename_ext . '$/' , '$1_' . date ( 'YmdHis' ) . '.' . $ filename_ext , $ startingPath ) ; if ( is_null ( $ startingPath ) ) { throw new \ Exception ( "The php function preg_replace (called in Excel::getUniqueFilePath()) returned null, indicating an error." ) ; } } return $ startingPath ; }
Given desired startingPath, this method will check if a file already exists at that location.
If a file with the same file name exists, this method will return a path with a timestamp
appended to the end of the intended file name.

@param string $startingPath

@return string
@throws \Exception
Given desired startingPath this method will check if a file already exists at that location . If a file with the same file name exists this method will return a path with a timestamp appended to the end of the intended file name .