Passed
Push — 1.x ( a9995e...5c2b79 )
by Aleksei
12:31
created

EntityRelation   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
c 1
b 0
f 0
dl 0
loc 19
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addRelation() 0 3 1
A __toString() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\Schema\Renderer\MermaidRenderer\Entity;
6
7
use Cycle\Schema\Renderer\MermaidRenderer\Relation;
8
9
final class EntityRelation implements EntityInterface
10
{
11
    /**
12
     * @var Relation[]
13
     */
14
    private array $relations = [];
15
16
    public function addRelation(Relation $relation): void
17
    {
18
        $this->relations[] = $relation;
19
    }
20
21
    public function __toString(): string
22
    {
23
        $relations = \array_map(function (Relation $relation) {
24
            return (string) $relation;
25
        }, $this->relations);
26
27
        return \implode("\n", $relations);
28
    }
29
}
30