Passed
Pull Request — 1.x (#13)
by
unknown
43:32 queued 28:34
created

ClassDiagram::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\Schema\Renderer\MermaidRenderer\Schema;
6
7
use Cycle\Schema\Renderer\MermaidRenderer\Entity\EntityInterface;
8
9
final class ClassDiagram implements SchemaInterface
10
{
11
    private const DIAGRAM = <<<DIAGRAM
12
13
    classDiagram
14
    %s
15
16
    DIAGRAM;
17
18
    private array $entities = [];
19
20
    public function __toString(): string
21
    {
22
        return sprintf(self::DIAGRAM, \implode("\n", $this->entities));
23
    }
24
25
    public function addEntity(EntityInterface $entity): void
26
    {
27
        $this->entities[] = $entity;
28
    }
29
}
30