InheritanceDecorator.php 955 Bytes
Newer Older
1
<?php declare(strict_types=1);
2
/*
Guillaume Perréal's avatar
CS.    
Guillaume Perréal committed
3
4
 * Copyright (C) 2016-2017 IRSTEA
 * All rights reserved.
5
6
7
8
 */

namespace Irstea\PlantUmlBundle\Model\Decorator;

9
use Irstea\PlantUmlBundle\Model\Arrow\ExtendsClass;
10
11
12
13
14
use Irstea\PlantUmlBundle\Model\ClassVisitorInterface;
use Irstea\PlantUmlBundle\Model\NodeInterface;
use ReflectionClass;

/**
Guillaume Perréal's avatar
CS.    
Guillaume Perréal committed
15
 * Description of InheritanceDecorator.
16
 */
17
class InheritanceDecorator extends AbstractRelationDecorator
18
{
19
    public function decorate(ReflectionClass $class, NodeInterface $node, ClassVisitorInterface $visitor)
20
21
22
    {
        $parent = $class->getParentClass();
        if ($parent) {
23
            $this->visitRelations($node, [$parent->getName()], $visitor);
24
25
26
        }
    }

27
    protected function buildRelation(NodeInterface $source, NodeInterface $target)
28
    {
29
        return new ExtendsClass($source, $target);
30
    }
31
32
33
34
35

    public function toConfig(array &$conf)
    {
        $conf['decorators'][] = 'inheritance';
    }
36
}