public function getProjectRootNamespaceFromComposerJson(
        string $dirForNamespace = 'src'
    ): string {
        try {
            $dirForNamespace = trim($dirForNamespace, '/');
            $jsonPath        = Config::getProjectRootDirectory() . '/composer.json';
            $json            = json_decode(\ts\file_get_contents($jsonPath), true);
            if (JSON_ERROR_NONE !== json_last_error()) {
                throw new \RuntimeException(
                    'Error decoding json from path ' . $jsonPath . ' , ' . json_last_error_msg()
                );
            }
            /**
             * @var string[][][][] $json
             */
            if (isset($json['autoload']['psr-4'])) {
                foreach ($json['autoload']['psr-4'] as $namespace => $dirs) {
                    foreach ($dirs as $dir) {
                        $dir = trim($dir, '/');
                        if ($dir === $dirForNamespace) {
                            return $this->tidy(rtrim($namespace, '\\'));
                        }
                    }
                }
            }
        } catch (\Exception $e) {
            throw new DoctrineStaticMetaException(
                'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
                $e->getCode(),
                $e
            );
        }
        throw new DoctrineStaticMetaException('Failed to find psr-4 namespace root');
    }