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

AnnotationHelper::getAnnotations()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3.0067

Importance

Changes 3
Bugs 1 Features 2
Metric Value
c 3
b 1
f 2
dl 0
loc 16
ccs 10
cts 11
cp 0.9091
rs 9.4285
cc 3
eloc 11
nc 3
nop 2
crap 3.0067
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
}