FlatNamespace.php 1.34 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php

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

namespace Irstea\PlantUmlBundle\Model\Namespace_;

use Irstea\PlantUmlBundle\Model\ArrowInterface;
use Irstea\PlantUmlBundle\Writer\WriterInterface;

/**
 * Description of RootNamespace
 *
 * @author Guillaume Perréal <guillaume.perreal@irstea.fr>
 */
class FlatNamespace extends AbstractNamespace
{
21
    const CONF_TYPE = 'flat';
22
23
    const SEPARATOR = 'none';

24
25
26
27
28
29
30
31
32
33
34
    /**
     * @var ArrowInterface[]
     */
    private $arrows = [];

    public function addArrow(ArrowInterface $arrow)
    {
        $this->arrows[] = $arrow;
        return $this;
    }

35
    public function writeTo(WriterInterface $writer)
36
    {
37
        $writer->writeFormatted("set namespaceSeparator %s\n", static::SEPARATOR);
38
        $this
39
40
            ->writeNodesTo($writer)
            ->writeArrowsTo($writer);
41
42
43
        return $this;
    }

44
    protected function writeArrowsTo(WriterInterface $writer)
45
46
    {
        foreach ($this->arrows as $arrow) {
47
            $arrow->writeTo($writer);
48
49
50
51
52
53
54
55
56
        }
        return $this;
    }

    public function getNamespace($namespaceName)
    {
        return $this;
    }

57
58
59
60
61
62
    public function getNodeId($name)
    {
        return str_replace('\\', '_', $name);
    }

    public function getNodeLabel($name)
63
64
65
66
    {
        return $name;
    }
}