private Collection < DependencyInfo > createDependencyInfos ( Collection < PhpPackage > phpPackages , Collection < DependencyInfo > dependencyInfos , Collection < String > directDependencies ) { HashMap < DependencyInfo , Collection < String > > parentToChildMap = new HashMap <> ( ) ; HashMap < String , DependencyInfo > packageDependencyMap = new HashMap <> ( ) ; // collect packages data and create its dependencyInfo for ( PhpPackage phpPackage : phpPackages ) { DependencyInfo dependencyInfo = createDependencyInfo ( phpPackage ) ; if ( dependencyInfo != null ) { parentToChildMap . put ( dependencyInfo , phpPackage . getPackageRequire ( ) . keySet ( ) ) ; packageDependencyMap . put ( phpPackage . getName ( ) , dependencyInfo ) ; } else { logger . debug ( "Didn't succeed to create dependencyInfo for {}" , phpPackage . getName ( ) ) ; } } if ( ! packageDependencyMap . isEmpty ( ) ) { for ( String directDependency : directDependencies ) { // create hierarchy tree DependencyInfo dependencyInfo = packageDependencyMap . get ( directDependency ) ; if ( dependencyInfo != null ) { collectChildren ( dependencyInfo , packageDependencyMap , parentToChildMap ) ; dependencyInfos . add ( dependencyInfo ) ; } else { logger . debug ( "Didn't found {} in map {}" , directDependency , packageDependencyMap . getClass ( ) . getName ( ) ) ; } } } else { logger . debug ( "The map {} is empty " , packageDependencyMap . getClass ( ) . getName ( ) ) ; } return dependencyInfos ; }
create dependencyInfo objects from each direct dependency