<commit_before><?php
namespace Tuum\Locator;

class Locator implements LocatorInterface
{
    /**
     * @var \SplStack|string[]
     */
    protected $dirs = [];

    /**
     * @param string $root
     */
    public function __construct($root = null)
    {
        $roots      = func_get_args();
        foreach ($roots as $root) {
            $this->addRoot($root);
        }
    }

    /**
     * @param string $root
     */
    public function addRoot($root)
    {
        if (substr($root, -1) !== '/') {
            $root .= '/';
        }
        $this->dirs[] = $root;
    }

    /**
     * @param string $file
     * @return bool|string
     */
    public function locate($file)
    {
        $file = substr($file,0,1) ==='/' ? substr($file,1) : $file;
        foreach ($this->dirs as $system) {
            $location = $system . $file;
            if (file_exists($location)) {
                return $location;
            }
        }
        return false;
    }
}<commit_msg>revert back; new config directory must be pushed to the beginning (i.e. new config overwrite the old one).<commit_after><?php
namespace Tuum\Locator;

class Locator implements LocatorInterface
{
    /**
     * @var \SplStack|string[]
     */
    protected $dirs = [];

    /**
     * @param string $root
     */
    public function __construct($root = null)
    {
        $this->dirs = new \SplStack();
        $roots      = func_get_args();
        foreach ($roots as $root) {
            $this->addRoot($root);
        }
    }

    /**
     * @param string $root
     */
    public function addRoot($root)
    {
        if (substr($root, -1) !== '/') {
            $root .= '/';
        }
        $this->dirs->push($root);
    }

    /**
     * @param string $file
     * @return bool|string
     */
    public function locate($file)
    {
        $file = substr($file,0,1) ==='/' ? substr($file,1) : $file;
        foreach ($this->dirs as $system) {
            $location = $system . $file;
            if (file_exists($location)) {
                return $location;
            }
        }
        return false;
    }
}
{'fraction_non_alphanumeric': 0.1596399810516343, 'fraction_numerical': 0.0037896731406916154, 'mean_word_length': 1.5945945945945945, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '2681783', 'n_tokens_mistral': 658, 'n_tokens_neox': 642, 'n_words': 143}