ConsoleStatsReporter::reportStats()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 0
cts 16
cp 0
rs 9.552
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Queryr\Replicator\Cli\Import;
4
5
use Queryr\Replicator\Importer\ImportStats;
6
use Queryr\Replicator\Importer\StatsReporter;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
/**
10
 * @licence GNU GPL v2+
11
 * @author Jeroen De Dauw < [email protected] >
12
 */
13
class ConsoleStatsReporter implements StatsReporter {
14
15
	private $output;
16
17
	public function __construct( OutputInterface $output ) {
18
		$this->output = $output;
19
	}
20
21
	public function reportStats( ImportStats $stats ) {
22
		$this->output->writeln( "\n" );
23
24
		$this->output->writeln( '<info>Import stats:</info>' );
25
26
		$this->output->writeln(
27
			sprintf(
28
				'<comment>Entities: %d (%d succeeded, %d (%g%%) failed)</comment>',
29
				$stats->getEntityCount(),
30
				$stats->getSuccessCount(),
31
				$stats->getErrorCount(),
32
				$stats->getErrorRatio()
33
			)
34
		);
35
36
		$this->output->writeln(
37
			sprintf(
38
				'<comment>Duration: %g seconds (%d entities/second)</comment>',
39
				$stats->getDurationInMs(),
40
				$stats->getEntityCount() / $stats->getDurationInMs()
41
			)
42
		);
43
	}
44
45
}
46