public function locateRootDirectory()
    {
        $vendorDirectoryName = 'vendor';
        $fileDirectory    = __DIR__;
        $searchDirectories = [
            __DIR__.'/..',
            __DIR__.'/../..',
            __DIR__.'/../../..',
            __DIR__.'/../../../..',
            __DIR__.'/../../../../..'
        ];

        $fileSystem = $this->createNew(FileSystem::class);
        foreach ($searchDirectories as $searchDirectory) {
            if ($fileSystem->fileExists($searchDirectory . '/' . $vendorDirectoryName)) {
                return $fileSystem->getRealPath($searchDirectory);
            }
        }

        throw new FileSystemException('No application root directory found');
    }