<commit_before><?php
/*
 * This file is part of VFS
 *
 * Copyright (c) 2014 <NAME> <http://adlawson.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Vfs;

use Psr\Log\LoggerInterface;
use Vfs\Exception\RegisteredSchemeException;
use Vfs\Exception\UnregisteredSchemeException;
use Vfs\Node\Factory\NodeFactoryInterface;
use Vfs\Node\Walker\NodeWalkerInterface;

class FileSystem implements FileSystemInterface
{
    protected $factory;
    protected $registry;
    protected $logger;
    protected $scheme;
    protected $walker;
    protected $wrapperClass;

    /**
     * @param string               $scheme
     * @param string               $wrapperClass
     * @param NodeFactoryInterface $factory
     * @param NodeWalkerInterface  $walker
     * @param RegistryInterface    $registry
     * @param LoggerInterface      $logger
     */
    public function __construct(
        $scheme,
        $wrapperClass,
        NodeFactoryInterface $factory,
        NodeWalkerInterface $walker,
        RegistryInterface $registry,
        LoggerInterface $logger
    ) {
        $this->wrapperClass = $wrapperClass;
        $this->scheme = $this->formatScheme($scheme);
        $this->walker = $walker;
        $this->logger = $logger;
        $this->factory = $factory;
        $this->registry = $registry;

        $this->root = $factory->buildDirectory();
    }

    /**
     * @param  string     $scheme
     * @return FileSystem
     */
    public static function factory($scheme = self::SCHEME)
    {
        $builder = new FileSystemBuilder($scheme);

        $fs = $builder->build();
        $fs->mount();

        return $fs;
    }

    /**
     * {@inheritdoc}
     */
    public function get($path)
    {
        return $this->walker->findNode($this->root, $path);
    }

    /**
     * {@inheritdoc}
     */
    public function getLogger()
    {
        return $this->logger;
    }

    /**
     * {@inheritdoc}
     */
    public function getNodeFactory()
    {
        return $this->factory;
    }

    /**
     * {@inheritdoc}
     */
    public function getNodeWalker()
    {
        return $this->walker;
    }

    /**
     * @return string
     */
    public function getScheme()
    {
        return $this->scheme;
    }

    /**
     * {@inheritdoc}
     */
    public function mount()
    {
        if ($this->registry->has($this->scheme) || in_array($this->scheme, stream_get_wrappers())) {
            throw new RegisteredSchemeException($this->scheme);
        }

        if (stream_wrapper_register($this->scheme, $this->wrapperClass)) {
            $this->registry->add($this->scheme, $this);

            return true;
        }

        return false;
    }

    /**
     * {@inheritdoc}
     */
    public function unmount()
    {
        if (!$this->registry->has($this->scheme) && !in_array($this->scheme, stream_get_wrappers())) {
            throw new UnregisteredSchemeException($this->scheme);
        }

        if (stream_wrapper_unregister($this->scheme)) {
            $this->registry->remove($this->scheme, $this);

            return true;
        }

        return false;
    }

    /**
     * @param  string $scheme
     * @return string
     */
    protected function formatScheme($scheme)
    {
        return rtrim($scheme, ':/\\');
    }
}<commit_msg>Don't automatically mount on FileSystem factory<commit_after><?php
/*
 * This file is part of VFS
 *
 * Copyright (c) 2014 <NAME> <http://adlawson.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Vfs;

use Psr\Log\LoggerInterface;
use Vfs\Exception\RegisteredSchemeException;
use Vfs\Exception\UnregisteredSchemeException;
use Vfs\Node\Factory\NodeFactoryInterface;
use Vfs\Node\Walker\NodeWalkerInterface;

class FileSystem implements FileSystemInterface
{
    protected $factory;
    protected $registry;
    protected $logger;
    protected $scheme;
    protected $walker;
    protected $wrapperClass;

    /**
     * @param string               $scheme
     * @param string               $wrapperClass
     * @param NodeFactoryInterface $factory
     * @param NodeWalkerInterface  $walker
     * @param RegistryInterface    $registry
     * @param LoggerInterface      $logger
     */
    public function __construct(
        $scheme,
        $wrapperClass,
        NodeFactoryInterface $factory,
        NodeWalkerInterface $walker,
        RegistryInterface $registry,
        LoggerInterface $logger
    ) {
        $this->wrapperClass = $wrapperClass;
        $this->scheme = rtrim($scheme, ':/\\');
        $this->walker = $walker;
        $this->logger = $logger;
        $this->factory = $factory;
        $this->registry = $registry;

        $this->root = $factory->buildDirectory();
    }

    /**
     * @param  string     $scheme
     * @return FileSystem
     */
    public static function factory($scheme = self::SCHEME)
    {
        $builder = new FileSystemBuilder($scheme);

        return $builder->build();
    }

    /**
     * {@inheritdoc}
     */
    public function get($path)
    {
        return $this->walker->findNode($this->root, $path);
    }

    /**
     * {@inheritdoc}
     */
    public function getLogger()
    {
        return $this->logger;
    }

    /**
     * {@inheritdoc}
     */
    public function getNodeFactory()
    {
        return $this->factory;
    }

    /**
     * {@inheritdoc}
     */
    public function getNodeWalker()
    {
        return $this->walker;
    }

    /**
     * @return string
     */
    public function getScheme()
    {
        return $this->scheme;
    }

    /**
     * {@inheritdoc}
     */
    public function mount()
    {
        if ($this->registry->has($this->scheme) || in_array($this->scheme, stream_get_wrappers())) {
            throw new RegisteredSchemeException($this->scheme);
        }

        if (stream_wrapper_register($this->scheme, $this->wrapperClass)) {
            $this->registry->add($this->scheme, $this);

            return true;
        }

        return false;
    }

    /**
     * {@inheritdoc}
     */
    public function unmount()
    {
        if (!$this->registry->has($this->scheme) && !in_array($this->scheme, stream_get_wrappers())) {
            throw new UnregisteredSchemeException($this->scheme);
        }

        if (stream_wrapper_unregister($this->scheme)) {
            $this->registry->remove($this->scheme, $this);

            return true;
        }

        return false;
    }
}
{'fraction_non_alphanumeric': 0.13054000907578278, 'fraction_numerical': 0.001210104371502042, 'mean_word_length': 2.127719962157048, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 79, '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': '5959882', 'n_tokens_mistral': 1895, 'n_tokens_neox': 1824, 'n_words': 398}