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

JBZoo / Mermaid-PHP / 7604212981

21 Jan 2024 10:26PM UTC coverage: 89.693% (-0.5%) from 90.214%
7604212981

push

github

web-flow
Fixed code style (#18)

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

9 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

93.33
/src/Helper.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;
18

19
use JBZoo\MermaidPHP\ClassDiagram\ClassDiagram;
20
use JBZoo\MermaidPHP\ERDiagram\ERDiagram;
21
use JBZoo\MermaidPHP\Timeline\Timeline;
22

23
class Helper
24
{
25
    public static function escape(string $text): string
26
    {
27
        $text = \trim($text);
140✔
28
        $text = \htmlentities($text, \ENT_COMPAT);
140✔
29
        $text = \str_replace(['&', '#lt;', '#gt;'], ['#', '<', '>'], $text);
140✔
30

31
        return "\"{$text}\"";
140✔
32
    }
33

34
    public static function getId(string $userFriendlyId): string
35
    {
36
        return \md5($userFriendlyId);
8✔
37
    }
38

39
    public static function getLiveEditorUrl(ClassDiagram|ERDiagram|Graph|Timeline $mermaid): string
40
    {
41
        $json = \json_encode([
4✔
42
            'code'    => (string)$mermaid,
4✔
43
            'mermaid' => [
2✔
44
                'theme' => 'forest',
2✔
45
            ],
2✔
46
        ]);
2✔
47

48
        if ($json === false) {
4✔
UNCOV
49
            throw new \RuntimeException('Can\'t encode graph to JSON');
×
50
        }
51

52
        $params = \base64_encode($json);
4✔
53

54
        return "https://mermaid-js.github.io/mermaid-live-editor/#/edit/{$params}";
4✔
55
    }
56
}
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