Helpers::fqcn()   A
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.2
c 0
b 0
f 0
cc 4
eloc 5
nc 2
nop 1
1
<?php
2
/**
3
 * Spiral Framework, IDE Helper
4
 *
5
 * @author    Dmitry Mironov <[email protected]>
6
 * @licence   MIT
7
 */
8
9
namespace Spiral\IdeHelper;
10
11
/**
12
 * Class Helpers
13
 *
14
 * @package Spiral\IdeHelper
15
 */
16
class Helpers
17
{
18
    /**
19
     * Return fully qualified class name. Support "typed arrays" syntax.
20
     *
21
     * @param string $name
22
     * @return string
23
     */
24
    public static function fqcn(string $name): string
25
    {
26
        $type = str_replace('[]', '', $name);
27
28
        if (class_exists($type) || interface_exists($type) && '\\' !== $type[0]) {
29
            return '\\' . $name;
30
        }
31
32
        return $name;
33
    }
34
}
35