Passed
Push — feature/mermaid ( 2f3e0e...fadc89 )
by
unknown
27:40 queued 12:43
created

Relation   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 16
c 1
b 0
f 0
dl 0
loc 36
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 7 2
A __construct() 0 12 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\Schema\Renderer\MermaidRenderer;
6
7
class Relation implements \Stringable
8
{
9
    use StringFormatter;
10
11
    private const BLOCK = '%s %s %s : %s';
12
13
    private string $parent;
14
15
    private string $children;
16
17
    private string $comment;
18
19
    private string $arrow;
20
    private bool $isNullable;
21
22
    public function __construct(
23
        string $parent,
24
        string $children,
25
        string $comment,
26
        string $arrow,
27
        bool $isNullable
28
    ) {
29
        $this->parent = $this->resolveString($parent);
30
        $this->children = $this->resolveString($children);
31
        $this->comment = $comment;
32
        $this->arrow = $arrow;
33
        $this->isNullable = $isNullable;
34
    }
35
36
    public function __toString(): string
37
    {
38
        if ($this->isNullable) {
39
            $this->arrow = $this->arrow . ' "nullable"';
40
        }
41
42
        return \sprintf(self::BLOCK, $this->parent, $this->arrow, $this->children, $this->comment);
43
    }
44
}
45