* Tous droits réservés. */ namespace Irstea\PlantUmlBundle\Model\Node; use Irstea\PlantUmlBundle\Model\UmlNodeInterface; /** * Description of Class * * @author Guillaume Perréal */ class BaseNode implements UmlNodeInterface { /** * @var string */ private $name; /** * @var string */ private $nodeType; /** * @var string[] */ private $classifiers; /** * @var string[] */ private $stereotypes; /** * @var int */ private $ordering; /** * @param string $name * @param string $nodeType * @param array $classifiers * @param array $stereotypes */ function __construct($name, $nodeType, array $classifiers = [], array $stereotypes = [], $ordering = 0) { $this->name = $name; $this->nodeType = $nodeType; $this->classifiers = $classifiers; $this->stereotypes = $stereotypes; $this->ordering = $ordering; } public function outputTo($stream) { $this->outputClassifiersTo($stream); $this->outputNodeTypeTo($stream); $this->outputAliasTo($stream); $this->outputStereotypesTo($stream); fputs($stream, " {\n"); $this->outputAttributesTo($stream); $this->outputMethodsTo($stream); fputs($stream, "}\n"); } public function outputAliasTo($stream) { fputs($stream, '"'.str_replace('\\', '.', $this->name).'"'); } protected function outputClassifiersTo($stream) { foreach($this->classifiers as $classifier) { fputs($stream, "$classifier "); } } protected function outputNodeTypeTo($stream) { fputs($stream, $this->nodeType." "); } protected function outputStereotypesTo($stream) { foreach($this->stereotypes as $stereotypes) { fputs($stream, " <<$stereotypes>>"); } } protected function outputAttributesTo($stream) { // NOP } protected function outputMethodsTo($stream) { // NOP } static public function compare(BaseNode $a, BaseNode $b) { if ($a->ordering === $b->ordering) { return strcmp($a->name, $b->name); } return $a->ordering - $b->ordering; } }