ClassNameUtils::getShortName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Dontdrinkandroot\Utils;
4
5
/**
6
 * @author Philip Washington Sorst <[email protected]>
7
 */
8
class ClassNameUtils
9
{
10
    public static function getShortName(string $className): string
11
    {
12
        $parts = explode("\\", $className);
13
        $lastPart = $parts[count($parts) - 1];
14
15
        return strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', $lastPart));
16
    }
17
}
18