JournalStats   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 91.67%

Importance

Changes 0
Metric Value
dl 0
loc 45
c 0
b 0
f 0
wmc 5
lcom 1
cbo 0
ccs 11
cts 12
cp 0.9167
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getNumRecords() 0 4 1
A getNumCompacted() 0 4 1
A getCompactedRate() 0 8 2
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