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

Relation   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
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 33
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
    private string $children;
15
    private string $comment;
16
    private string $arrow;
17
    private bool $isNullable;
18
19
    public function __construct(
20
        string $parent,
21
        string $children,
22
        string $comment,
23
        string $arrow,
24
        bool $isNullable
25
    ) {
26
        $this->parent = $this->resolveString($parent);
27
        $this->children = $this->resolveString($children);
28
        $this->comment = $comment;
29
        $this->arrow = $arrow;
30
        $this->isNullable = $isNullable;
31
    }
32
33
    public function __toString(): string
34
    {
35
        if ($this->isNullable) {
36
            $this->arrow = $this->arrow . ' "nullable"';
37
        }
38
39
        return \sprintf(self::BLOCK, $this->parent, $this->arrow, $this->children, $this->comment);
40
    }
41
}
42