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

JBZoo / Mermaid-PHP / 10176799226

22 Jun 2024 09:08AM UTC coverage: 88.769%. Remained the same
10176799226

push

github

web-flow
Remove redundant escape characters (#22)

411 of 463 relevant lines covered (88.77%)

60.46 hits per line

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

86.67
/src/ClassDiagram/Concept/Method.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\Concept;
18

19
use JBZoo\MermaidPHP\Exception;
20

21
class Method implements \Stringable
22
{
23
    public function __construct(
24
        protected string $name,
25
        /** @var Argument[] */
26
        protected array $arguments = [],
27
        protected ?string $returnType = null,
28
        protected ?Visibility $visibility = null,
29
        protected bool $isAbstract = false,
30
        protected bool $isStatic = false,
31
    ) {
32
        if ($this->isAbstract && $this->isStatic) {
6✔
33
            throw new Exception('A method could not be both abstract and static');
×
34
        }
35
    }
36

37
    public function __toString(): string
38
    {
39
        $output = [];
6✔
40

41
        $output[] = \sprintf('%s(%s)', $this->name, \implode(',', $this->arguments));
6✔
42

43
        if ($this->returnType !== null) {
6✔
44
            $output[] = $this->returnType;
6✔
45
        }
46

47
        return $this->renderVisibility() . \implode(' ', $output) . $this->renderClassifier();
6✔
48
    }
49

50
    private function renderVisibility(): string
51
    {
52
        if ($this->visibility === null) {
6✔
53
            return '';
6✔
54
        }
55

56
        return $this->visibility->value;
6✔
57
    }
58

59
    private function renderClassifier(): string
60
    {
61
        if ($this->isStatic) {
6✔
62
            return '$';
6✔
63
        }
64

65
        if ($this->isAbstract) {
6✔
66
            return '*';
6✔
67
        }
68

69
        return '';
×
70
    }
71
}
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

© 2026 Coveralls, Inc