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

Result::getBoolExpressionsCount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
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