• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JBZoo / Mermaid-PHP / 7634240466

21 Jan 2024 10:26PM UTC coverage: 89.693%. Remained the same
7634240466

push

github

web-flow
Fixed code style (#18)

1 of 2 new or added lines in 1 file covered. (50.0%)

7 existing lines in 2 files now uncovered.

409 of 456 relevant lines covered (89.69%)

34.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

61.29
/src/ClassDiagram/ClassDiagram.php
1
<?php
2

3
/**
4
 * JBZoo Toolbox - Mermaid-PHP.
5
 *
6
 * This file is part of the JBZoo Toolbox project.
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license    MIT
11
 * @copyright  Copyright (C) JBZoo.com, All rights reserved.
12
 * @see        https://github.com/JBZoo/Mermaid-PHP
13
 */
14

15
declare(strict_types=1);
16

17
namespace JBZoo\MermaidPHP\ClassDiagram;
18

19
use JBZoo\MermaidPHP\ClassDiagram\Concept\Concept;
20
use JBZoo\MermaidPHP\ClassDiagram\ConceptNamespace\ConceptNamespace;
21
use JBZoo\MermaidPHP\ClassDiagram\Relationship\Relationship;
22
use JBZoo\MermaidPHP\Direction;
23
use JBZoo\MermaidPHP\Helper;
24
use JBZoo\MermaidPHP\Render;
25

26
class ClassDiagram
27
{
28
    protected ?string $title        = null;
29
    protected ?Direction $direction = null;
30

31
    /** @var ConceptNamespace[] */
32
    protected array $namespaces = [];
33

34
    /** @var Concept[] */
35
    protected array $classes = [];
36

37
    /** @var Relationship[] */
38
    protected array $relationships = [];
39

40
    public function __toString(): string
41
    {
42
        return $this->render();
12✔
43
    }
44

45
    public function setTitle(string $title): self
46
    {
47
        $this->title = $title;
4✔
48

49
        return $this;
4✔
50
    }
51

52
    public function setDirection(Direction $direction): self
53
    {
54
        $this->direction = $direction;
4✔
55

56
        return $this;
4✔
57
    }
58

59
    public function addClass(Concept $class): self
60
    {
61
        $this->classes[$class->getId()] = $class;
4✔
62

63
        return $this;
4✔
64
    }
65

66
    public function addNamespace(ConceptNamespace $namespace): self
67
    {
68
        $this->namespaces[] = $namespace;
×
69

70
        return $this;
×
71
    }
72

73
    public function addRelationship(Relationship $relationship): self
74
    {
75
        $this->relationships[] = $relationship;
×
76

77
        return $this;
×
78
    }
79

80
    public function render(): string
81
    {
82
        $result = [];
12✔
83

84
        if ($this->title !== null) {
12✔
85
            $result[] = \sprintf('---%s---', \PHP_EOL . 'title: ' . $this->title . \PHP_EOL);
4✔
86
        }
87

88
        $result[] = 'classDiagram';
12✔
89

90
        if ($this->direction !== null) {
12✔
91
            $result[] = \sprintf('direction %s', $this->direction->value);
4✔
92
        }
93

94
        foreach ($this->namespaces as $namespace) {
12✔
95
            $result[] = $namespace;
×
96
        }
97

98
        foreach ($this->classes as $class) {
12✔
99
            $result[] = $class;
4✔
100
        }
101

102
        foreach ($this->relationships as $relationship) {
12✔
103
            $result[] = $relationship;
×
104
        }
105

106
        $result[] = '';
12✔
107

108
        return \implode(\PHP_EOL, $result);
12✔
109
    }
110

111
    /**
112
     * @suppress PhanPossiblyUndeclaredProperty
113
     */
114
    public function getParams(): array
115
    {
UNCOV
116
        return \array_filter([
×
UNCOV
117
            'title'     => $this->title,
×
UNCOV
118
            'direction' => $this->direction?->value,
×
119
        ], static fn ($value) => $value !== null);
×
120
    }
121

122
    /**
123
     * @param  array<string>  $params
124
     * @throws \JsonException
125
     */
126
    public function renderHtml(array $params = []): string
127
    {
UNCOV
128
        return Render::html($this, $params);
×
129
    }
130

131
    public function getLiveEditorUrl(): string
132
    {
UNCOV
133
        return Helper::getLiveEditorUrl($this);
×
134
    }
135
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc