An error occurred while loading the file. Please try again.
-
Guillaume Perréal authoredd56eec09
<?php declare(strict_types=1);
/*
* Copyright (C) 2016-2018 IRSTEA
* All rights reserved.
*/
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.
*/
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);
}
}