An error occurred while loading the file. Please try again.
-
Guillaume Perréal authored
Et de même pour toutes les méthodes write*To.
a6e19bcf
<?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\Namespace_\AbstractNamespace as Base;
use Irstea\PlantUmlBundle\Model\NamespaceInterface;
use Irstea\PlantUmlBundle\Writer\WriterInterface;
/**
* Description of Namespace
*
* @author Guillaume Perréal <guillaume.perreal@irstea.fr>
*/
abstract class AbstractNamespace extends Base
{
/**
* @var NamespaceInterface
*/
private $children = [];
/**
* @param type $namespaceName
* @return NamespaceInterface
*/
public function getNamespace($namespaceName)
{
$namespaceName = trim($namespaceName, '\\');
if (!$namespaceName) {
return $this;
}
@list($head, $tail) = explode('\\', $namespaceName, 2);
if (!isset($this->children[$head])) {
$this->children[$head] = new Namespace_($this, $head);
}
if (empty($tail)) {
return $this->children[$head];
}
return $this->children[$head]->getNamespace($tail);
}
/**
* @return $string
*/
abstract protected function getNamespacePrefix();
public function getNodeId($name)
{
return str_replace('\\', '.', $name).'_node';
}
/**
* @param WriterInterface $writer
* @return self
*/
protected function writeChildrenTo(WriterInterface $writer)
{
foreach ($this->children as $child) {
$child->writeTo($writer);
}
return $this;
}
/**
* @return bool
71727374757677
*/
protected function isEmpty()
{
return parent::isEmpty() && empty($this->children);
}
}