JournalStats::getCompactedRate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 3
cts 4
cp 0.75
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2.0625
1
<?php
2
/**
3
 * File was created 23.04.2015 16:31
4
 */
5
6
namespace PeekAndPoke\Component\Slumber\Data\Addon\Journal\DomainModel;
7
8
/**
9
 * @author Karsten J. Gerber <[email protected]>
10
 */
11
class JournalStats
12
{
13
    /** @var int */
14
    private $numRecords;
15
    /** @var int */
16
    private $numCompacted;
17
18
    /**
19
     * @param int $numRecords
20
     * @param int $numCompacted
21
     */
22 2
    public function __construct($numRecords, $numCompacted)
23
    {
24 2
        $this->numRecords   = $numRecords;
25 2
        $this->numCompacted = $numCompacted;
26 2
    }
27
28
    /**
29
     * @return int
30
     */
31 2
    public function getNumRecords()
32
    {
33 2
        return $this->numRecords;
34
    }
35
36
    /**
37
     * @return int
38
     */
39 2
    public function getNumCompacted()
40
    {
41 2
        return $this->numCompacted;
42
    }
43
44
    /**
45
     * @return float
46
     */
47 2
    public function getCompactedRate()
48
    {
49 2
        if ($this->numRecords === 0) {
50
            return 1.0;
51
        }
52
53 2
        return $this->numCompacted / $this->numRecords;
54
    }
55
}
56