Completed
Push — master ( 9634df...f1462e )
by Nikola
08:19
created

ClassUtils::isClassNameValid()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 0
cts 9
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 3
nop 1
crap 12
1
<?php
2
3
namespace RunOpenCode\AbstractBuilder\Utils;
4
5
final class ClassUtils
6
{
7
    private function __construct() { /* noop */ }
8
9
    public static function isClassNameValid($fqcn)
10
    {
11
        foreach (explode('\\', ltrim($fqcn, '\\')) as $part) {
12
13
            if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $part)) {
14
                return false;
15
            }
16
        }
17
18
        return true;
19
    }
20
}
21