CodeView

PHPUnit test harness for Komodo

Tools.php

<?php
 
    class Tools {
 
        /**
         * Adds a trailing slash or backslash to a directory path.
         *
         * @param  string $dirpath
         * @return string
         */
        public static function add_trailing_slash ( $dirpath ) {
 
            return ( preg_match( '%.*?[/\\\\]$%', $dirpath, $matches ) ? $matches[0] : $dirpath . DIRECTORY_SEPARATOR );
 
        }
 
        /**
         * Removes a trailing slash or backslash from a directory path.
         *
         * @param  string $dirpath
         * @return string
         */
        public static function remove_trailing_slash ( $dirpath ) {
 
            return ( preg_match( '%(.*?)[/\\\\]$%', $dirpath, $matches ) ? $matches[1] : $dirpath );
 
        }
 
    }
 
?>