FlatNamespace.php 1.28 KB
Newer Older
1
<?php declare(strict_types=1);
2
/*
Guillaume Perréal's avatar
CS.    
Guillaume Perréal committed
3
4
 * Copyright (C) 2016-2017 IRSTEA
 * All rights reserved.
5
6
7
8
9
10
11
12
 */

namespace Irstea\PlantUmlBundle\Model\Namespace_;

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

/**
Guillaume Perréal's avatar
CS.    
Guillaume Perréal committed
13
 * Description of RootNamespace.
14
15
16
 */
class FlatNamespace extends AbstractNamespace
{
17
18
    public const CONF_TYPE = 'flat';
    public const SEPARATOR = 'none';
19

20
21
22
23
24
25
26
27
    /**
     * @var ArrowInterface[]
     */
    private $arrows = [];

    public function addArrow(ArrowInterface $arrow)
    {
        $this->arrows[] = $arrow;
Guillaume Perréal's avatar
CS.    
Guillaume Perréal committed
28

29
30
31
        return $this;
    }

32
    public function writeTo(WriterInterface $writer)
33
    {
34
        $writer->writeFormatted("set namespaceSeparator %s\n", static::SEPARATOR);
35
        $this
36
37
            ->writeNodesTo($writer)
            ->writeArrowsTo($writer);
Guillaume Perréal's avatar
CS.    
Guillaume Perréal committed
38

39
40
41
        return $this;
    }

42
    protected function writeArrowsTo(WriterInterface $writer)
43
44
    {
        foreach ($this->arrows as $arrow) {
45
            $arrow->writeTo($writer);
46
        }
Guillaume Perréal's avatar
CS.    
Guillaume Perréal committed
47

48
49
50
51
52
53
54
55
        return $this;
    }

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

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

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