src/phpDocumentor/Plugin/Graphs/Writer/Graph.php
public function processClass(ProjectDescriptor $project, Transformation $transformation)
    {
        try {
            $this->checkIfGraphVizIsInstalled();
        } catch (\Exception $e) {
            echo $e->getMessage();

            return;
        }

        if ($transformation->getParameter('font') !== null && $transformation->getParameter('font')->getValue()) {
            $this->nodeFont = $transformation->getParameter('font')->getValue();
        } else {
            $this->nodeFont = 'Courier';
        }

        $filename = $this->getDestinationPath($transformation);

        $graph = GraphVizGraph::create()
            ->setRankSep('1.0')
            ->setCenter('true')
            ->setRank('source')
            ->setRankDir('RL')
            ->setSplines('true')
            ->setConcentrate('true');

        $this->buildNamespaceTree($graph, $project->getNamespace());

        $classes    = $project->getIndexes()->get('classes', new Collection())->getAll();
        $interfaces = $project->getIndexes()->get('interfaces', new Collection())->getAll();
        $traits     = $project->getIndexes()->get('traits', new Collection())->getAll();

        /** @var ClassDescriptor[]|InterfaceDescriptor[]|TraitDescriptor[] $containers  */
        $containers = array_merge($classes, $interfaces, $traits);

        foreach ($containers as $container) {
            $from_name = $container->getFullyQualifiedStructuralElementName();

            $parents     = array();
            $implemented = array();
            if ($container instanceof ClassDescriptor) {
                if ($container->getParent()) {
                    $parents[] = $container->getParent();
                }
                $implemented = $container->getInterfaces()->getAll();
            }
            if ($container instanceof InterfaceDescriptor) {
                $parents = $container->getParent()->getAll();
            }

            /** @var string|ClassDescriptor|InterfaceDescriptor $parent */
            foreach ($parents as $parent) {
                $edge = $this->createEdge($graph, $from_name, $parent);
                $edge->setArrowHead('empty');
                $graph->link($edge);
            }

            /** @var string|ClassDescriptor|InterfaceDescriptor $parent */
            foreach ($implemented as $parent) {
                $edge = $this->createEdge($graph, $from_name, $parent);
                $edge->setStyle('dotted');
                $edge->setArrowHead('empty');
                $graph->link($edge);
            }
        }

        $graph->export('svg', $filename);
    }
public function processClass(ProjectDescriptor $project, Transformation $transformation)
    {
        try {
            $this->checkIfGraphVizIsInstalled();
        } catch (\Exception $e) {
            echo $e->getMessage();

            return;
        }

        if ($transformation->getParameter('font') !== null && $transformation->getParameter('font')->getValue()) {
            $this->nodeFont = $transformation->getParameter('font')->getValue();
        } else {
            $this->nodeFont = 'Courier';
        }

        $filename = $this->getDestinationPath($transformation);

        $graph = GraphVizGraph::create()
            ->setRankSep('1.0')
            ->setCenter('true')
            ->setRank('source')
            ->setRankDir('RL')
            ->setSplines('true')
            ->setConcentrate('true');

        $this->buildNamespaceTree($graph, $project->getNamespace());

        $classes    = $project->getIndexes()->get('classes', new Collection())->getAll();
        $interfaces = $project->getIndexes()->get('interfaces', new Collection())->getAll();
        $traits     = $project->getIndexes()->get('traits', new Collection())->getAll();

        /** @var ClassDescriptor[]|InterfaceDescriptor[]|TraitDescriptor[] $containers  */
        $containers = array_merge($classes, $interfaces, $traits);

        foreach ($containers as $container) {
            $from_name = $container->getFullyQualifiedStructuralElementName();

            $parents     = array();
            $implemented = array();
            if ($container instanceof ClassDescriptor) {
                if ($container->getParent()) {
                    $parents[] = $container->getParent();
                }
                $implemented = $container->getInterfaces()->getAll();
            }
            if ($container instanceof InterfaceDescriptor) {
                $parents = $container->getParent()->getAll();
            }

            /** @var string|ClassDescriptor|InterfaceDescriptor $parent */
            foreach ($parents as $parent) {
                $edge = $this->createEdge($graph, $from_name, $parent);
                $edge->setArrowHead('empty');
                $graph->link($edge);
            }

            /** @var string|ClassDescriptor|InterfaceDescriptor $parent */
            foreach ($implemented as $parent) {
                $edge = $this->createEdge($graph, $from_name, $parent);
                $edge->setStyle('dotted');
                $edge->setArrowHead('empty');
                $graph->link($edge);
            }
        }

        $graph->export('svg', $filename);
    }
public function processClass ( ProjectDescriptor $ project , Transformation $ transformation ) { try { $ this -> checkIfGraphVizIsInstalled ( ) ; } catch ( \ Exception $ e ) { echo $ e -> getMessage ( ) ; return ; } if ( $ transformation -> getParameter ( 'font' ) !== null && $ transformation -> getParameter ( 'font' ) -> getValue ( ) ) { $ this -> nodeFont = $ transformation -> getParameter ( 'font' ) -> getValue ( ) ; } else { $ this -> nodeFont = 'Courier' ; } $ filename = $ this -> getDestinationPath ( $ transformation ) ; $ graph = GraphVizGraph :: create ( ) -> setRankSep ( '1.0' ) -> setCenter ( 'true' ) -> setRank ( 'source' ) -> setRankDir ( 'RL' ) -> setSplines ( 'true' ) -> setConcentrate ( 'true' ) ; $ this -> buildNamespaceTree ( $ graph , $ project -> getNamespace ( ) ) ; $ classes = $ project -> getIndexes ( ) -> get ( 'classes' , new Collection ( ) ) -> getAll ( ) ; $ interfaces = $ project -> getIndexes ( ) -> get ( 'interfaces' , new Collection ( ) ) -> getAll ( ) ; $ traits = $ project -> getIndexes ( ) -> get ( 'traits' , new Collection ( ) ) -> getAll ( ) ; /** @var ClassDescriptor[]|InterfaceDescriptor[]|TraitDescriptor[] $containers  */ $ containers = array_merge ( $ classes , $ interfaces , $ traits ) ; foreach ( $ containers as $ container ) { $ from_name = $ container -> getFullyQualifiedStructuralElementName ( ) ; $ parents = array ( ) ; $ implemented = array ( ) ; if ( $ container instanceof ClassDescriptor ) { if ( $ container -> getParent ( ) ) { $ parents [ ] = $ container -> getParent ( ) ; } $ implemented = $ container -> getInterfaces ( ) -> getAll ( ) ; } if ( $ container instanceof InterfaceDescriptor ) { $ parents = $ container -> getParent ( ) -> getAll ( ) ; } /** @var string|ClassDescriptor|InterfaceDescriptor $parent */ foreach ( $ parents as $ parent ) { $ edge = $ this -> createEdge ( $ graph , $ from_name , $ parent ) ; $ edge -> setArrowHead ( 'empty' ) ; $ graph -> link ( $ edge ) ; } /** @var string|ClassDescriptor|InterfaceDescriptor $parent */ foreach ( $ implemented as $ parent ) { $ edge = $ this -> createEdge ( $ graph , $ from_name , $ parent ) ; $ edge -> setStyle ( 'dotted' ) ; $ edge -> setArrowHead ( 'empty' ) ; $ graph -> link ( $ edge ) ; } } $ graph -> export ( 'svg' , $ filename ) ; }
Creates a class inheritance diagram.

@param ProjectDescriptor $project
@param Transformation    $transformation

@return void
Creates a class inheritance diagram .