Completed
Push — master ( 9d7f2b...8fe48d )
by Lars
24:45
created

ArrayyMeta   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 29
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getMetaObject() 0 21 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arrayy;
6
7
class ArrayyMeta {
8
9
    /**
10
     * @param string $obj
11
     *
12
     * @return $this
13
     */
14 7
    public function getMetaObject(string $obj) {
15 7
        static $STATIC_CACHE = array();
16
17 7
        $cacheKey = $obj;
18 7
        if (!empty($STATIC_CACHE[$cacheKey])) {
19 6
            return $STATIC_CACHE[$cacheKey];
20
        }
21
22 2
        $reflector = new \ReflectionClass($obj);
23 2
        $factory  = \phpDocumentor\Reflection\DocBlockFactory::createInstance();
24 2
        $docblock = $factory->create($reflector->getDocComment());
25 2
        foreach ($docblock->getTagsByName('property') as $tag) {
26
          /* @var $tag \phpDocumentor\Reflection\DocBlock\Tags\Property */
27 2
          $PropertyName = $tag->getVariableName();
28 2
          $this->{$PropertyName} = $PropertyName;
29
        }
30
31 2
        $STATIC_CACHE[$cacheKey] = $this;
32
33 2
        return $this;
34
    }
35
}
36