CoveredClass   A
last analyzed

Complexity

Total Complexity 17

Size/Duplication

Total Lines 113
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 17
lcom 1
cbo 1
dl 0
loc 113
rs 10
c 0
b 0
f 0

12 Methods

Rating   Name   Duplication   Size   Complexity  
A setName() 0 4 1
A getName() 0 4 1
A addLine() 0 4 1
A getLines() 0 4 1
A __toString() 0 4 1
A getNamespace() 0 4 1
A setNamespace() 0 4 1
A getMethods() 0 10 4
A getLine() 0 4 1
A setFilename() 0 4 1
A getFilename() 0 4 1
A isCovered() 0 10 3
1
<?php
2
3
4
namespace PHPRealCoverage\Parser\Model;
5
6
use PHPRealCoverage\Proxy\ClassMetadata;
7
use PHPRealCoverage\Proxy\Line;
8
9
class CoveredClass implements ClassMetadata
10
{
11
    /**
12
     * @var string
13
     */
14
    private $name;
15
16
    /**
17
     * @var Line[]
18
     */
19
    private $lines = array();
20
    private $namespace;
21
22
    private $filename;
23
24
    /**
25
     * @param string $name
26
     */
27
    public function setName($name)
28
    {
29
        $this->name = $name;
30
    }
31
32
    /**
33
     * @return string
34
     */
35
    public function getName()
36
    {
37
        return $this->name;
38
    }
39
40
    /**
41
     * @param integer $lineNumber
42
     * @param \PHPRealCoverage\Proxy\Line $line
43
     */
44
    public function addLine($lineNumber, Line $line)
45
    {
46
        $this->lines[$lineNumber] = $line;
47
    }
48
49
    public function getLines()
50
    {
51
        return $this->lines;
52
    }
53
54
    public function __toString()
55
    {
56
        return join("\n", $this->lines);
57
    }
58
59
    public function getNamespace()
60
    {
61
        return $this->namespace;
62
    }
63
64
    /**
65
     * @param string $namespace
66
     */
67
    public function setNamespace($namespace)
68
    {
69
        $this->namespace = $namespace;
70
    }
71
72
    /**
73
     * @return string[]
74
     */
75
    public function getMethods()
76
    {
77
        $methods = array();
78
        foreach ($this->lines as $line) {
79
            if ($line->isMethod() && !$line->isConstructor()) {
80
                $methods[] = $line->getMethodName();
81
            }
82
        }
83
        return $methods;
84
    }
85
86
    /**
87
     * @param int $lineNumber
88
     * @return Line
89
     */
90
    public function getLine($lineNumber)
91
    {
92
        return @$this->lines[$lineNumber];
93
    }
94
95
    /**
96
     * @param mixed $filename
97
     */
98
    public function setFilename($filename)
99
    {
100
        $this->filename = $filename;
101
    }
102
103
    /**
104
     * @return mixed
105
     */
106
    public function getFilename()
107
    {
108
        return $this->filename;
109
    }
110
111
    public function isCovered()
112
    {
113
        foreach ($this->getLines() as $line) {
114
            if ($line->isCovered()) {
115
                return true;
116
            }
117
        }
118
119
        return false;
120
    }
121
}
122