protected function createRelationIndex(array $modules) : array
    {
        $index = [];

        foreach ($modules as $moduleName => $module) {
            if (! isset($module['relations'])) {
                $index[$moduleName] = [];
                continue;
            }

            if (! is_array($module['relations'])) {
                $index[$moduleName] = [];
                continue;
            }

            foreach ($module['relations'] as $relatedModule) {
                if (!empty($index[$relatedModule][$moduleName])) {
                    continue;
                }
                $index[$relatedModule][] = $moduleName;
            }
        }

        return $index;
    }