RootNamespace.php 1.17 KB
Newer Older
1
<?php declare(strict_types=1);
2
/*
Guillaume Perréal's avatar
CS.  
Guillaume Perréal committed
3
 * Copyright (C) 2016-2018 IRSTEA
Guillaume Perréal's avatar
CS.  
Guillaume Perréal committed
4
 * All rights reserved.
5 6
 */

7
namespace Irstea\PlantUmlBundle\Model\Namespace_\Php;
8

9
use Irstea\PlantUmlBundle\Model\ArrowInterface;
10 11
use Irstea\PlantUmlBundle\Writer\WriterInterface;

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

19
    /**
20
     * @var ArrowInterface[]
21 22 23
     */
    private $arrows = [];

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

28 29 30
        return $this;
    }

31
    public function writeTo(WriterInterface $writer)
32
    {
33
        $writer->write("set namespaceSeparator .\n");
34
        $this
35 36 37
            ->writeNodesTo($writer)
            ->writeChildrenTo($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
        return $this;
    }
50 51 52

    protected function getNamespacePrefix()
    {
Guillaume Perréal's avatar
CS.  
Guillaume Perréal committed
53
        return '';
54
    }
55 56 57 58 59

    public function getNodeLabel($className)
    {
        return $className;
    }
60
}