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

ClassUtils   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 16
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 16
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 1 1
A isClassNameValid() 0 11 3
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