<commit_before><?php
/**
 * Some utility methods for vfsStream.
 *
 * @package  bovigo_vfs
 * @version  $Id$
 */
/**
 * @ignore
 */
require_once dirname(__FILE__) . '/vfsStreamWrapper.php';
/**
 * Some utility methods for vfsStream.
 *
 * @package  bovigo_vfs
 */
class vfsStream
{
    /**
     * url scheme
     */
    const SCHEME       = 'vfs';
    /**
     * owner: root
     */
    const OWNER_ROOT   = 0;
    /**
     * owner: user 1
     */
    const OWNER_USER_1 = 1;
    /**
     * owner: user 2
     */
    const OWNER_USER_2 = 2;
    /**
     * group: root
     */
    const GROUP_ROOT   = 0;
    /**
     * group: user 1
     */
    const GROUP_USER_1 = 1;
    /**
     * group: user 2
     */
    const GROUP_USER_2 = 2;

    /**
     * prepends the scheme to the given URL
     *
     * @param   string  $path
     * @return  string
     */
    public static function url($path)
    {
        return self::SCHEME . '://' . str_replace('\\', '/', $path);
    }

    /**
     * restores the path from the url
     *
     * @param   string  $url
     * @return  string
     */
    public static function path($url)
    {
        // remove line feeds and trailing whitespaces
        $path = trim($url, " \t\r\n\0\x0B/");
        $path = substr($path, strlen(self::SCHEME . '://'));
        $path = str_replace('\\', '/', $path);
        // replace double slashes with single slashes
        $path = str_replace('//', '/', $path);
        return $path;
    }

    /**
     * helper method for setting up vfsStream in unit tests
     *
     * @param   string              $rootDirName  optional  name of root directory
     * @param   int                 $permissions  optional  file permissions of root directory
     * @return  vfsStreamDirectory<commit_msg>improve doc comment<commit_after><?php
/**
 * Some utility methods for vfsStream.
 *
 * @package  bovigo_vfs
 * @version  $Id$
 */
/**
 * @ignore
 */
require_once dirname(__FILE__) . '/vfsStreamWrapper.php';
/**
 * Some utility methods for vfsStream.
 *
 * @package  bovigo_vfs
 */
class vfsStream
{
    /**
     * url scheme
     */
    const SCHEME       = 'vfs';
    /**
     * owner: root
     */
    const OWNER_ROOT   = 0;
    /**
     * owner: user 1
     */
    const OWNER_USER_1 = 1;
    /**
     * owner: user 2
     */
    const OWNER_USER_2 = 2;
    /**
     * group: root
     */
    const GROUP_ROOT   = 0;
    /**
     * group: user 1
     */
    const GROUP_USER_1 = 1;
    /**
     * group: user 2
     */
    const GROUP_USER_2 = 2;

    /**
     * prepends the scheme to the given URL
     *
     * @param   string  $path
     * @return  string
     */
    public static function url($path)
    {
        return self::SCHEME . '://' . str_replace('\\', '/', $path);
    }

    /**
     * restores the path from the url
     *
     * @param   string  $url
     * @return  string
     */
    public static function path($url)
    {
        // remove line feeds and trailing whitespaces
        $path = trim($url, " \t\r\n\0\x0B/");
        $path = substr($path, strlen(self::SCHEME . '://'));
        $path = str_replace('\\', '/', $path);
        // replace double slashes with single slashes
        $path = str_replace('//', '/', $path);
        return $path;
    }

    /**
     * helper method for setting up vfsStream in unit tests
     *
     * Instead of
     * vfsStreamWrapper::register();
     * vfsStreamWrapper::setRoot(vfsStream::newDirectory('root'));
     * you can simply do
     * vfsStream::setup()
     * which yields the same result.
     *
     * @param   string              $rootDirName  optional  name of root directory
     * @param   int                 $permissions  optional  file permissions of root directory
     * @return  vfsStreamDirectory
{'fraction_non_alphanumeric': 0.1382611007710715, 'fraction_numerical': 0.00850837543206594, 'mean_word_length': 1.7221418234442836, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5616972', 'n_tokens_mistral': 1252, 'n_tokens_neox': 1203, 'n_words': 317}