Completed
Branch master (f5a858)
by Алексей
02:55
created

AnnotationHelper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 90.91%

Importance

Changes 3
Bugs 1 Features 2
Metric Value
wmc 3
c 3
b 1
f 2
lcom 0
cbo 0
dl 0
loc 20
ccs 10
cts 11
cp 0.9091
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
9
namespace Telegram\Helpers;
10
11
12
class AnnotationHelper
13
{
14
    
15 1
    public static function getAnnotations($class, $value)
16
    {
17 1
        $propertyReflect = new \ReflectionProperty($class, $value);
18 1
        $doc             = $propertyReflect->getDocComment();
19 1
        if (!preg_match_all('#@(.*?)\n#s', $doc, $annotations)) {
20
            return false;
21
        };
22 1
        $annotations = $annotations[1];
23 1
        $return      = [];
24 1
        foreach ($annotations as $annotation) {
25 1
            list($k, $v) = array_pad(explode(' ', $annotation, 2), 2, null);
26 1
            $return[$k] = $v;
27
        }
28
29 1
        return $return;
30
    }
31
}