Completed
Pull Request — master (#7)
by Алексей
03:07
created

AnnotationHelper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 91.67%

Importance

Changes 4
Bugs 2 Features 2
Metric Value
wmc 3
c 4
b 2
f 2
lcom 0
cbo 0
dl 0
loc 19
ccs 11
cts 12
cp 0.9167
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getAnnotations() 0 16 3
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: akeinhell
5
 * Date: 29.06.16
6
 * Time: 13:00.
7
 */
8
namespace Telegram\Helpers;
9
10
class AnnotationHelper
11
{
12 2
    public static function getAnnotations($class, $value)
13
    {
14 2
        $propertyReflect = new \ReflectionProperty($class, $value);
15 2
        $doc = $propertyReflect->getDocComment();
16 2
        if (!preg_match_all('#@(.*?)\n#s', $doc, $annotations)) {
17
            return false;
18
        }
19 2
        $annotations = $annotations[1];
20 2
        $return = [];
21 2
        foreach ($annotations as $annotation) {
22 2
            list($k, $v) = array_pad(explode(' ', $annotation, 2), 2, null);
23 2
            $return[$k] = $v;
24 2
        }
25
26 2
        return $return;
27
    }
28
}
29