AbstractTypeResult   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 7
c 2
b 1
f 0
lcom 1
cbo 6
dl 0
loc 71
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A getNamespaceName() 0 4 1
A getChildResults() 0 4 1
A getMethodResults() 0 12 2
A hasChildResults() 0 5 1
A __construct() 0 5 1
1
<?php
2
3
/**
4
 * This file is part of cloak.
5
 *
6
 * (c) Noritaka Horio <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace cloak\result;
13
14
use cloak\result\collection\CoverageResultCollection;
15
use cloak\reflection\ClassReflection;
16
17
18
/**
19
 * Class AbstractTypeResult
20
 * @package cloak\result
21
 */
22
abstract class AbstractTypeResult
23
{
24
25
    use CoverageResult;
26
27
    /**
28
     * @var ClassReflection
29
     */
30
    private $reflection;
31
32
33
    /**
34
     * @param ClassReflection $reflection
35
     * @param LineResultSelectable $selector
36
     */
37
    public function __construct(ClassReflection $reflection, LineResultSelectable $selector)
38
    {
39
        $this->reflection = $reflection;
40
        $this->lineResults = $selector->selectByReflection($this->reflection);
41
    }
42
43
    /**
44
     * @return string
45
     */
46
    public function getName()
47
    {
48
        return $this->reflection->getName();
49
    }
50
51
    /**
52
     * @return string
53
     */
54
    public function getNamespaceName()
55
    {
56
        return $this->reflection->getNamespaceName();
57
    }
58
59
    /**
60
     * @return \cloak\result\CoverageResultNodeCollection
61
     */
62
    public function getMethodResults()
63
    {
64
        $results = new CoverageResultCollection();
65
        $methods = $this->reflection->getMethods();
66
67
        foreach ($methods as $method) {
68
            $methodResult = new MethodResult($method, $this->lineResults);
69
            $results->add($methodResult);
70
        }
71
72
        return $results;
73
    }
74
75
    /**
76
     * @return bool
77
     */
78
    public function hasChildResults()
79
    {
80
        $methods = $this->reflection->getMethods();
81
        return $methods->isEmpty() === false;
82
    }
83
84
    /**
85
     * @return CoverageResultNodeCollection
86
     */
87
    public function getChildResults()
88
    {
89
        return $this->getMethodResults();
90
    }
91
92
}
93