lithium\console\command\Test::_path PHP Method

_path() protected method

This method can be thought of the reverse of Libraries::path(). lithium/tests/cases/core/ObjectTest.php -> lithium\tests\cases\core\ObjectTest lithium/tests/cases/core -> lithium\tests\cases\core lithium/core/Object.php -> lithium\core\Object lithium/core/ -> lithium\core lithium/core -> lithium\core
See also: lithium\core\Libraries::path()
protected _path ( string $path ) : string
$path string The directory of or file path to one or more classes.
return string Returns a fully-namespaced class path, or `false`, if an error occurs.
    protected function _path($path)
    {
        $path = rtrim(str_replace('\\', '/', $path), '/');
        if (!$path) {
            $this->error('Please provide a path to tests.');
            return false;
        }
        if ($path[0] === '/') {
            $library = $this->_library($path);
        }
        if ($path[0] !== '/') {
            $libraries = array_reduce(Libraries::get(), function ($v, $w) {
                $v[] = basename($w['path']);
                return $v;
            });
            $library = $this->_library($this->request->env('working') . '/' . $path);
            $parts = explode('/', str_replace("../", "", $path));
            $plugin = array_shift($parts);
            if ($plugin === 'libraries') {
                $plugin = array_shift($parts);
            }
            if (in_array($plugin, $libraries)) {
                $library = $plugin;
                $path = join('/', $parts);
            }
        }
        if (empty($library)) {
            $this->error("No library found in path `{$path}`.");
            return false;
        }
        if (!($config = Libraries::get($library))) {
            $this->error("Library `{$library}` does not exist.");
            return false;
        }
        $path = str_replace($config['path'], null, $path);
        $realpath = $config['path'] . '/' . $path;
        if (!realpath($realpath)) {
            $this->error("Path `{$realpath}` not found.");
            return false;
        }
        $class = str_replace(".php", "", str_replace('/', '\\', ltrim($path, '/')));
        return $config['prefix'] . $class;
    }