public static function get(Composer $composer): ?ProjectTypeInterface
    {
        $rootDir = dirname($composer->getConfig()->getConfigSource()->getName());

        $classes = static::getClasses($composer);

        $composerProjectType = $composer->getPackage()->getExtra()['rikudou']['installer']['project-type'] ?? null;
        if ($composerProjectType && isset($classes[$composerProjectType])) {
            $class = $classes[$composerProjectType];

            return new $class;
        }

        foreach ($classes as $class) {
            /** @var ProjectTypeInterface $instance */
            $instance = new $class;
            foreach ($instance->getDirs() as $dir) {
                if (is_array($dir)) {
                    $exists = true;
                    foreach ($dir as $requiredDir) {
                        $exists = $exists && file_exists("{$rootDir}/{$requiredDir}");
                    }
                    if ($exists) {
                        return $instance;
                    }
                } else {
                    if (file_exists("{$rootDir}/{$dir}")) {
                        return $instance;
                    }
                }
            }
        }

        return null;
    }
public static function get(Composer $composer): ?ProjectTypeInterface
    {
        $rootDir = dirname($composer->getConfig()->getConfigSource()->getName());

        $classes = static::getClasses($composer);

        $composerProjectType = $composer->getPackage()->getExtra()['rikudou']['installer']['project-type'] ?? null;
        if ($composerProjectType && isset($classes[$composerProjectType])) {
            $class = $classes[$composerProjectType];

            return new $class;
        }

        foreach ($classes as $class) {
            /** @var ProjectTypeInterface $instance */
            $instance = new $class;
            foreach ($instance->getDirs() as $dir) {
                if (is_array($dir)) {
                    $exists = true;
                    foreach ($dir as $requiredDir) {
                        $exists = $exists && file_exists("{$rootDir}/{$requiredDir}");
                    }
                    if ($exists) {
                        return $instance;
                    }
                } else {
                    if (file_exists("{$rootDir}/{$dir}")) {
                        return $instance;
                    }
                }
            }
        }

        return null;
    }
public static function get ( Composer $ composer ) : ? ProjectTypeInterface { $ rootDir = dirname ( $ composer -> getConfig ( ) -> getConfigSource ( ) -> getName ( ) ) ; $ classes = static :: getClasses ( $ composer ) ; $ composerProjectType = $ composer -> getPackage ( ) -> getExtra ( ) [ 'rikudou' ] [ 'installer' ] [ 'project-type' ] ?? null ; if ( $ composerProjectType && isset ( $ classes [ $ composerProjectType ] ) ) { $ class = $ classes [ $ composerProjectType ] ; return new $ class ; } foreach ( $ classes as $ class ) { /** @var ProjectTypeInterface $instance */ $ instance = new $ class ; foreach ( $ instance -> getDirs ( ) as $ dir ) { if ( is_array ( $ dir ) ) { $ exists = true ; foreach ( $ dir as $ requiredDir ) { $ exists = $ exists && file_exists ( "{$rootDir}/{$requiredDir}" ) ; } if ( $ exists ) { return $ instance ; } } else { if ( file_exists ( "{$rootDir}/{$dir}" ) ) { return $ instance ; } } } } return null ; }
Returns the project type, either from composer extra section or it tries to detect from file structure.
Returns null if no project type is detected.

@param Composer $composer

@return null|ProjectTypeInterface
Returns the project type either from composer extra section or it tries to detect from file structure . Returns null if no project type is detected .