Completed
Push — master ( 96b2f8...da2c9c )
by Kirill
05:58
created

Renderer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 29
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A typeName() 0 7 1
A oneOf() 0 10 3
1
<?php
2
/**
3
 * This file is part of Railt package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Railt\Reflection\Common;
11
12
/**
13
 * Class Renderer
14
 */
15
class Renderer
16
{
17
    /**
18
     * @param string $name
19
     * @return string
20
     */
21
    public static function typeName(string $name): string
22
    {
23
        $name = \str_replace(['-', '_'], ' ', $name);
24
        $name = \ucwords($name);
25
26
        return (string)\str_replace(' ', '', $name);
27
    }
28
29
    /**
30
     * @param iterable|string[] $names
31
     * @return string
32
     */
33
    public static function oneOf(iterable $names): string
34
    {
35
        $result = \implode(', ', $names instanceof \Traversable ? \iterator_to_array($names) : $names);
36
37
        if (($position = \strrpos($result, ', ')) !== false) {
38
            return \substr_replace($result, ' or ', $position, 2);
39
        }
40
41
        return $result;
42
    }
43
}
44