Completed
Push — master ( 7f17d7...74e687 )
by Rick
11s
created

Result   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 0
dl 0
loc 67
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A addAssumption() 0 8 1
A increaseBoolExpressionsCount() 0 4 1
A getAssumptions() 0 4 1
A getAssumptionsCount() 0 4 1
A getBoolExpressionsCount() 0 4 1
A getPercentage() 0 8 2
1
<?php
2
3
namespace PhpAssumptions\Output;
4
5
class Result
6
{
7
    /**
8
     * @var array
9
     */
10
    private $assumptions = [];
11
12
    /**
13
     * @var int
14
     */
15
    private $boolExpressionsCount = 0;
16
17
    /**
18
     * @param string $file
19
     * @param int    $line
20
     * @param string $message
21
     */
22 6
    public function addAssumption($file, $line, $message)
23
    {
24 6
        $this->assumptions[] = [
25 6
            'file' => $file,
26 6
            'line' => $line,
27 6
            'message' => $message,
28
        ];
29 6
    }
30
31 6
    public function increaseBoolExpressionsCount()
32
    {
33 6
        $this->boolExpressionsCount++;
34 6
    }
35
36
    /**
37
     * @return array
38
     */
39 5
    public function getAssumptions()
40
    {
41 5
        return $this->assumptions;
42
    }
43
44
    /**
45
     * @return int
46
     */
47 6
    public function getAssumptionsCount()
48
    {
49 6
        return count($this->assumptions);
50
    }
51
52
    /**
53
     * @return float
54
     */
55 6
    public function getPercentage()
56
    {
57 6
        if ($this->getBoolExpressionsCount() === 0) {
58 2
            return 0;
59
        }
60
61 4
        return round($this->getAssumptionsCount() / $this->getBoolExpressionsCount() * 100);
62
    }
63
64
    /**
65
     * @return int
66
     */
67 7
    public function getBoolExpressionsCount()
68
    {
69 7
        return $this->boolExpressionsCount;
70
    }
71
}
72