Une mise-à-jour est prévue le 9 juillet entre 13:00 et 14:00. Le service sera inaccessible ou instable pendant cette période. Merci de votre compréhension.

TypedSymbol.php 1.16 KB
Newer Older
1
<?php declare(strict_types=1);
2
/*
Guillaume Perréal's avatar
CS.  
Guillaume Perréal committed
3
 * Copyright (C) 2016-2018 IRSTEA
Guillaume Perréal's avatar
CS.  
Guillaume Perréal committed
4
 * All rights reserved.
5 6 7 8 9 10 11 12
 */

namespace Irstea\PlantUmlBundle\Model;

use Irstea\PlantUmlBundle\Writer\WritableInterface;
use Irstea\PlantUmlBundle\Writer\WriterInterface;

/**
Guillaume Perréal's avatar
CS.  
Guillaume Perréal committed
13
 * Description of TypedSymbol.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
 */
class TypedSymbol implements WritableInterface
{
    /**
     * @var string
     */
    private $type;

    /**
     * @var string
     */
    private $symbol;

    /**
     * @param type $symbol
     * @param type $type
     */
    public function __construct($symbol, $type = false)
    {
Guillaume Perréal's avatar
CS.  
Guillaume Perréal committed
33
        $this->type = $type;
34 35 36 37 38
        $this->symbol = $symbol;
    }

    /**
     * @param WriterInterface $writer
Guillaume Perréal's avatar
CS.  
Guillaume Perréal committed
39
     *
40 41 42 43 44 45 46 47 48 49
     * @return TypedSymbol
     */
    public function writeTo(WriterInterface $writer)
    {
        return $this->writeTypeTo($writer)->writeSymbolTo($writer);
    }

    protected function writeTypeTo(WriterInterface $writer)
    {
        if ($this->type) {
Guillaume Perréal's avatar
CS.  
Guillaume Perréal committed
50
            $writer->writeFormatted('%s ', $this->type);
51
        }
Guillaume Perréal's avatar
CS.  
Guillaume Perréal committed
52

53 54 55 56 57 58
        return $this;
    }

    protected function writeSymbolTo(WriterInterface $writer)
    {
        $writer->write($this->symbol);
Guillaume Perréal's avatar
CS.  
Guillaume Perréal committed
59

60 61 62
        return $this;
    }
}