public function analyze($directory)
    {
        if (!$this->fileSystem->exists($directory) || !$this->fileSystem->isDirectory($directory)) {
            throw new InvalidPathException($directory . ' is not a valid directory.');
        }

        $structure = $this->fileSystem->allFiles($directory);

        $newStructure = [];

        foreach ($structure as $path) {
            $type = ($this->fileSystem->isFile($path)) ? 'file' : 'dir';
            $newStructure[] = [
                'path' => $this->normalizePath($path->getRelativePathName()),
                'type' => $type,
                'origin' => $this->normalizePath($path->getRealPath()),
                'home' => $this->normalizePath(substr($path->getRealPath(), 0, (-1 * strlen($path->getRelativePathName()))))
            ];
        }

        return $newStructure;
    }