An error occurred while loading the file. Please try again.
-
Guillaume Perréal authored5f91175d
<?php
/*
* © 2016 IRSTEA
* Guillaume Perréal <guillaume.perreal@irstea.fr>
* Tous droits réservés.
*/
namespace Irstea\PlantUmlBundle\Model\Namespace_\Php;
use Irstea\PlantUmlBundle\Model\ArrowInterface;
use Irstea\PlantUmlBundle\Writer\WriterInterface;
/**
* Description of Namespace
*
* @author Guillaume Perréal <guillaume.perreal@irstea.fr>
*/
class Namespace_ extends AbstractNamespace
{
/**
* @var AbstractNamespace
*/
private $parent;
/**
* @var string
*/
private $name;
public function __construct(AbstractNamespace $parent, $name)
{
$this->parent = $parent;
$this->name = $name;
}
/**
* @param ArrowInterface $arrow
* @return self
*/
public function addArrow(ArrowInterface $arrow)
{
$this->parent->addArrow($arrow);
return $this;
}
/**
* @return string
*/
protected function getNamespacePrefix()
{
return $this->parent->getNamespacePrefix() . $this->name . '\\';
}
public function getNodeLabel($name)
{
$prefix = $this->getNamespacePrefix();
if (0 === strpos($name, $prefix)) {
return substr($name, strlen($prefix));
}
return $name;
}
/**
* @param resource WriterInterface $writer
* @return self
*/
public function writeTo(WriterInterface $writer)
{
if ($this->isEmpty()) {
7172737475767778798081828384858687
return;
}
$writer
->writeFormatted("namespace %s {\n", $this->name)
->indent();
$this
->writeNodesTo($writer)
->writeChildrenTo($writer);
$writer
->dedent()
->write("}\n");
return $this;
}
}