Graph.php 1.26 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php

/*
 * © 2016 IRSTEA
 * Guillaume Perréal <guillaume.perreal@irstea.fr>
 * Tous droits réservés.
 */

namespace Irstea\PlantUmlBundle\Model;

use Irstea\PlantUmlBundle\Finder\FinderInterface;
use Irstea\PlantUmlBundle\Writer\WriterInterface;

/**
 * Description of Graph
 *
 * @author Guillaume Perréal <guillaume.perreal@irstea.fr>
 */
class Graph implements GraphInterface
{
    /**
     * @var ClassVisitorInterface
     */
    private $visitor;

    /**
     * @var FinderInterface
     */
    private $finder;

    public function __construct(ClassVisitorInterface $visitor, FinderInterface $finder)
    {
        $this->visitor = $visitor;
        $this->finder  = $finder;
    }

    public function visitAll()
    {
        foreach($this->finder->getIterator() as $class) {
            $this->visitor->visitClass($class);
        }
    }

44
    public function writeTo(WriterInterface $writer)
45
46
    {
        $writer->write("@startuml@\n");
47
        $this->visitor->writeTo($writer);
48
49
50
        $writer->write("@enduml@\n");
        return $this;
    }
51
52
53
54
55
56
57
58
59
60

    /**
     * @param array $conf
     */
    public function toConfig(array &$conf)
    {
        $conf['sources'] = [];
        $this->finder->toConfig($conf['sources']);
        $this->visitor->toConfig($conf);
    }
61
}