ImportStats::recordSuccess()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Queryr\Replicator\Importer;
4
5
/**
6
 * @licence GNU GPL v2+
7
 * @author Jeroen De Dauw < [email protected] >
8
 */
9
class ImportStats {
10
11
	private $count = 0;
12
	private $errorCount = 0;
13
	private $durationInMs;
14
15 5
	public function recordSuccess() {
16 5
		$this->count++;
17 5
	}
18
19 5
	public function recordError( \Exception $ex ) {
0 ignored issues
show
Unused Code introduced by
The parameter $ex is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
20 5
		$this->count++;
21 5
		$this->errorCount++;
22 5
	}
23
24 1
	public function setDuration( float $durationInMs ) {
25 1
		$this->durationInMs = $durationInMs;
26 1
	}
27
28 2
	public function getEntityCount(): int {
29 2
		return $this->count;
30
	}
31
32 1
	public function getErrorCount(): int {
33 1
		return $this->errorCount;
34
	}
35
36 1
	public function getSuccessCount(): int {
37 1
		return $this->count - $this->errorCount;
38
	}
39
40 4
	public function getErrorRatio(): float {
41 4
		if ( $this->count === 0 ) {
42 1
			return 0;
43
		}
44
45 3
		return $this->errorCount / $this->count * 100;
46
	}
47
48
	public function getDurationInMs(): float {
49
		return $this->durationInMs;
50
	}
51
52
}