Passed
Pull Request — 1.x (#13)
by
unknown
28:20 queued 13:19
created

StringFormatter::resolveString()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 2
nc 2
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\Schema\Renderer\MermaidRenderer;
6
7
trait StringFormatter
8
{
9
    private function resolveString(string $value): string
10
    {
11
        if (\preg_match('/[^_a-zA-Z0-9]/u', $value)) {
12
            $value = \preg_replace('/[^a-z0-9_]/u', '_', $value);
13
        }
14
15
        return $value;
16
    }
17
18
    /**
19
     * @param class-string|object $class
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string|object at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string|object.
Loading history...
20
     */
21
    private function getClassShortName($class): string
22
    {
23
        $className = \is_object($class) ? \get_class($class) : $class;
24
25
        return \substr($className, ((int)\strrpos($className, '\\')) + 1);
26
    }
27
}
28