ParsedClass   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 58
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
B getMethods() 0 16 5
A getNamespace() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ParaTest\Parser;
6
7
class ParsedClass extends ParsedObject
8
{
9
    /**
10
     * @var string
11
     */
12
    private $namespace;
13
14
    /**
15
     * A collection of methods belonging
16
     * to the parsed class.
17
     *
18
     * @var array
19
     */
20
    private $methods;
21
22 35
    public function __construct(string $doc, string $name, string $namespace, array $methods = [])
23
    {
24 35
        parent::__construct($doc, $name);
25 35
        $this->namespace = $namespace;
26 35
        $this->methods = $methods;
27 35
    }
28
29
    /**
30
     * Return the methods of this parsed class
31
     * optionally filtering on annotations present
32
     * on a method.
33
     *
34
     * @param array $annotations
35
     *
36
     * @return array
37
     */
38
    public function getMethods(array $annotations = []): array
39
    {
40 24
        $methods = array_filter($this->methods, function (ParsedFunction $method) use ($annotations): bool {
41 24
            foreach ($annotations as $a => $v) {
42 3
                foreach (explode(',', $v) as $subValue) {
43 3
                    if ($method->hasAnnotation($a, $subValue)) {
44 3
                        return true;
45
                    }
46
                }
47
            }
48
49 24
            return false;
50 24
        });
51
52 24
        return $methods ? $methods : $this->methods;
53
    }
54
55
    /**
56
     * Return the namespace of the parsed class.
57
     *
58
     * @return string
59
     */
60 1
    public function getNamespace(): string
61
    {
62 1
        return $this->namespace;
63
    }
64
}
65