An error occurred while loading the file. Please try again.
-
Guillaume Perréal authored
Et laisse tomber le classement.
709da3ad
<?php
/*
* © 2016 IRSTEA
* Guillaume Perréal <guillaume.perreal@irstea.fr>
* Tous droits réservés.
*/
namespace Irstea\PlantUmlBundle\Model\Node;
use Irstea\PlantUmlBundle\Model\ArrowInterface;
use Irstea\PlantUmlBundle\Model\NamespaceInterface;
use Irstea\PlantUmlBundle\Model\NodeInterface;
use Irstea\PlantUmlBundle\Writer\WriterInterface;
/**
* Description of Class
*
* @author Guillaume Perréal <guillaume.perreal@irstea.fr>
*/
class BaseNode implements NodeInterface
{
/**
* @var string
*/
private $name;
/**
* @var string
*/
private $alias;
/**
* @var string
*/
private $nodeType;
/**
* @var string[]
*/
private $classifiers;
/**
* @var string[]
*/
private $stereotypes;
/**
* @var NamespaceInterface
*/
private $namespace;
/**
* @param NamespaceInterface $namespace
* @param string $name
* @param string $nodeType
* @param array $classifiers
* @param array $stereotypes
*/
function __construct(NamespaceInterface $namespace, $name, $nodeType, array $classifiers = [], array $stereotypes = [])
{
$this->namespace = $namespace;
$pos = strrpos($name, '\\');
$this->name = substr($name, $pos + 1);
$this->alias = str_replace('\\', '.', $name)."_node";
$this->nodeType = $nodeType;
$this->classifiers = $classifiers;
$this->stereotypes = $stereotypes;
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
}
public function outputTo(WriterInterface $writer)
{
$this
->outputClassifiersTo($writer)
->outputNodeTypeTo($writer);
$writer->printf('"%s" as %s', $this->name, $this->alias);
$this
->outputStereotypesTo($writer);
$writer
->write(" {\n")
->indent();
$this
->outputAttributesTo($writer)
->outputMethodsTo($writer);
$writer
->dedent()
->write("}\n");
return $this;
}
public function outputAliasTo(WriterInterface $writer)
{
$writer->write($this->alias);
return $this;
}
protected function outputClassifiersTo(WriterInterface $writer)
{
foreach($this->classifiers as $classifier) {
$writer->printf('%s ', $classifier);
}
return $this;
}
protected function outputNodeTypeTo(WriterInterface $writer)
{
$writer->printf('%s ', $this->nodeType);
return $this;
}
protected function outputStereotypesTo(WriterInterface $writer)
{
foreach($this->stereotypes as $stereotype) {
$writer->printf(' <<%s>>', $stereotype);
}
return $this;
}
protected function outputAttributesTo(WriterInterface $writer)
{
return $this;
}
protected function outputMethodsTo(WriterInterface $writer)
{
return $this;
}
public function addArrow(ArrowInterface $arrow)
{
$this->namespace->addArrow($arrow);
return $this;
}
}