TypeReflector   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 21
wmc 2
lcom 0
cbo 0
ccs 4
cts 4
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getTypeName() 0 8 2
1
<?php
2
3
namespace mindplay\unravel;
4
5
use ReflectionParameter;
6
7
/**
8
 * This class provides a means of obtaining a parameter type-hint without auto-loading the parameter type.
9
 */
10
abstract class TypeReflector
11
{
12
    /**
13
     * @var string pattern for parsing an argument type from a ReflectionParameter string
14
     */
15
    const ARG_PATTERN = '/(?:\<required\>|\<optional\>)\\s+([\\w\\\\]+)/';
16
17
    /**
18
     * @param ReflectionParameter $param
19
     *
20
     * @return string|null fully-qualified parameter type-name (or NULL, if no type-hint was found)
21
     */
22 1
    public static function getTypeName(ReflectionParameter $param)
23
    {
24 1
        if (preg_match(TypeReflector::ARG_PATTERN, $param->__toString(), $matches) === 1) {
25 1
            return $matches[1];
26
        }
27
28 1
        return null;
29
    }
30
}
31