Failed to fetch fork details. Try again later.
-
unknown authored5dce7a71
Forked from
HYCAR-Hydro / airGR
Source project has a limited visibility.
<?php
/*
* © 2016 IRSTEA
* Guillaume Perréal <guillaume.perreal@irstea.fr>
* Tous droits réservés.
*/
namespace Irstea\PlantUmlBundle\Model;
use Irstea\PlantUmlBundle\Writer\WriterInterface;
/**
* Description of Namespace
*
* @author Guillaume Perréal <guillaume.perreal@irstea.fr>
*/
abstract class AbstractNamespace implements UmlComponentInterface, NamespaceInterface
{
/**
* @var UmlNodeInterface[]
*/
private $nodes = [];
/**
* @var NamespaceInterface
*/
private $children = [];
/**
*
* @param UmlNodeInterface $node
*/
public function addNode(UmlNodeInterface $node)
{
$this->nodes[] = $node;
return $this;
}
/**
* @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);
}
/**
* @param WriterInterface $writer
* @return self
*/
protected function outputNodesTo(WriterInterface $writer)
{
foreach ($this->nodes as $node) {
$node->outputTo($writer);
}
return $this;
}
71727374757677787980818283848586878889909192
/**
* @param WriterInterface $writer
* @return self
*/
protected function outputChildrenTo(WriterInterface $writer)
{
foreach ($this->children as $child) {
$child->outputTo($writer);
}
return $this;
}
/**
* @return bool
*/
protected function isEmpty()
{
return empty($this->children) && empty($this->nodes);
}
}