@param array  $metaData
@param string $basePath

@return array
490485
private function normalizeMetadata(array $metaData, string $basePath): array
    {
        if (empty($basePath)) {
            $basePath = '.';
        }

        if (empty($metaData['path'])) {
            $metaData['path'] = '.';
        }

        if (empty($metaData['type'])) {
            $metaData['type'] = 'dir';
        }

        if ($metaData['path'] == $basePath) {
            if ('file' == $metaData['type']) {
                $parts = explode('/', $metaData['path']);
                $metaData['path'] = array_pop($parts);
            } else {
                $metaData['path'] = '.';
            }
        } elseif ('.' != $basePath) {
            $metaData['path'] = substr($metaData['path'], strlen($basePath) + 1);
        }

        if (isset($metaData['size'])) {
            $metaData['size'] = $this->humanFileSize($metaData['size']);
        } else {
            $metaData['size'] = '';
        }

        return $metaData;
    }
611135
public function getPathRelativeTo($basePath)
    {
        $basePath = $this->purifyPath($basePath).static::SEPARATOR_DIRECTORY;

        $relativePath = $this->getPath();
        $prefix = mb_substr($relativePath, 0, mb_strlen($basePath));
        if ($prefix === $basePath) {
            $relativePath = mb_substr($relativePath, mb_strlen($prefix));
        }

        return $relativePath;
    }
655407
public function generate($namespace, $basePath, ClassMetadata $metadata)
    {
        $entityName = $this->getEntityNameFromMetadata($metadata);
        $fileName = sprintf(
            '%s/Manager/%sManager.php',
            $basePath,
            $entityName
        );

        $parameters = array(
            'namespace' => $namespace,
            'entityName' => $entityName,
            'metadata' => $metadata,
        );

        return $this->renderFile('manager.php.twig', $fileName, $parameters);
    }
193679
public function basePath($basePath = null)
    {
        if (null === $basePath) {
            return $this->basePath;
        }

        $this->basePath = $basePath;
        return $this;
    }
208598
public function findPath($classname, $basepath = null)
    {
        $path = false;

        /*
         * Exception rule for Exception classes
        *
        * Transform class to lower case to always load the exception class from the /exception/ folder.
        */
        if ($pos = strpos($classname, 'Exception')) {
            $filename = substr($classname, $pos + strlen('Exception'));
            $classname = str_replace($filename, ucfirst(strtolower($filename)), $classname);
        }

        $word = strtolower(preg_replace('/(?<=\\w)([A-Z])/', ' \\1', $classname));

        $parts = explode(' ', $word);

        if (array_shift($parts) == 'com') {
            //Switch the basepath
            if (!empty($basepath)) {
                $this->_basepath = $basepath;
            }

            $component = 'com_'.strtolower(array_shift($parts));
            $file = array_pop($parts);
            $path = null;
            if (!empty($parts)) {
                if ($parts[0] != 'view') {
                    foreach ($parts as $key => $value) {
                        $parts[$key] = AnInflector::pluralize($value);
                    }
                } else {
                    $parts[0] = AnInflector::pluralize($parts[0]);
                }
                $path = implode('/', $parts);
            }

            $path = '/components/'.$component.'/'.$path;

            $filepath = $path.'/'.$file.'.php';
            $basepath = $this->_basepath;

            if (array_value($parts, -1) == 'exceptions') {
                if (!file_exists($basepath.$filepath)) {
                    $filepath = $path.'/default.php';
                }
            }

            if (count($parts) == 2 && $parts[0] == 'domains') {
                if ($parts[1] == 'entities' && ANPATH_SITE != $this->_basepath) {
                    //set the basepath of entities to the site
                    if (!file_exists($basepath.$filepath)) {
                        $basepath = ANPATH_SITE;
                    }
                }
            }

            $path = $basepath.$filepath;
        }

        return $path;
    }
141587
public static Collection<String> getBasePaths(String basePath) {
        return Collections2.transform(Lists.newArrayList(basePath.split(",")),
                s -> s.startsWith("/") ? s.substring(1) : s);
    }
899905
public function setBasePath($basePath)
    {
        $this['path.app'] = rtrim($basePath);

        foreach (['config', 'views', 'logs'] as $v) {
            $this['path.' . $v] = realpath(rtrim($basePath) . '/' . $v) . DIRECTORY_SEPARATOR;
        }

        $this['namespace.controller'] = '';

        return $this;
    }
194296
public function build($basepath, $language = null)
    {
        $sitemapElements = [];

        foreach ($this->sitemapElementGenerators as $sitemapElementGenerator) {
            $sitemapElements = array_merge(
                $sitemapElements,
                $sitemapElementGenerator->generateElements($language)
            );
        }

        $data = $this
            ->sitemapRenderer
            ->render($sitemapElements, $basepath);

        return $data;
    }
1065044
private function addBasePath($path)
    {
        if (\strpos($path, $this->basePath) === 0) {
            return $path;
        }

        return \str_replace('//', '/', $this->basePath . '/' . $path);
    }
966357
public function getMetadata(string $path): array
    {
        $parameters = [
            'path' => $this->normalizePath($path),
        ];

        return $this->rpcEndpointRequest('files/get_metadata', $parameters);
    }
562255
public function basePath($basePath = null)
    {
        if (!func_num_args()) {
            return $this->_basePath;
        }
        $this->_basePath = $basePath;
        return $this;
    }
1087633
public function getFilesList( $basePath )
    {
        // The custom iterator filters out the file path in order to get a relative one
        return new eZDFSFileHandlerDFSBackendFilterIterator(
            new RecursiveIteratorIterator(
                new RecursiveDirectoryIterator(
                    $this->mountPointPath . '/' . $basePath,
                    FilesystemIterator::SKIP_DOTS|FilesystemIterator::UNIX_PATHS
                )
            ),
            $this->mountPointPath
        );
    }
1106914
public function getStorageBaseDirectory($basePath = null)
    {
        // Get base storage path configuration
        $storage = $this->get('storage');

        // Check if storage is relative to the application path or not
        $relative = $storage['path_is_relative'] ?: true;

        return ($relative ? $basePath . DIRECTORY_SEPARATOR : '') . $storage['base_dir'];
    }
137714
public static function normalizeDataSource($dataSource, $basePath = null)
    {
        if (!empty($basePath) && !Utils::isHttpSource($dataSource)) {
            // TODO: support JSON pointers
            $absPath = $basePath.DIRECTORY_SEPARATOR.$dataSource;
            if (file_exists($absPath)) {
                $dataSource = $absPath;
            }
        }

        return $dataSource;
    }
496132
public function createApplication(?string $basePath = null): self
    {
        $basePath ?: $basePath = realpath(__DIR__.'/../../../../../');

        $this->app = new Application($basePath);

        return $this;
    }
314998
public function resolve(
        AbsolutePathInterface $basePath,
        PathInterface $path
    ) {
        if ($path instanceof AbsolutePathInterface) {
            return $path;
        }

        return $basePath->join($path);
    }
1157047
public function handle($path, array $metadata)
    {
        $object = $this->filesystem->getMetadata($path);

        if ( ! $object) {
            return false;
        }

        $keys = array_diff($metadata, array_keys($object));

        foreach ($keys as $key) {
            if ( ! method_exists($this->filesystem, $method = 'get' . ucfirst($key))) {
                throw new InvalidArgumentException('Could not fetch metadata: ' . $key);
            }

            $object[$key] = $this->filesystem->{$method}($path);
        }

        return $object;
    }