LoggingReporter::stepStarted()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Queryr\Replicator\Importer;
4
5
use Exception;
6
use Psr\Log\LoggerInterface;
7
use Queryr\Replicator\Model\EntityPage;
8
9
/**
10
 * @licence GNU GPL v2+
11
 * @author Jeroen De Dauw < [email protected] >
12
 */
13
class LoggingReporter implements PageImportReporter {
14
15
	private $logger;
16
17
	private $number = 0;
18
19
	public function __construct( LoggerInterface $logger ) {
20
		$this->logger = $logger;
21
	}
22
23
	public function started( EntityPage $entityPage ) {
24
		$this->logger->info( "Importing entity " . ++$this->number . ': ' . $entityPage->getTitle() . '...' );
25
	}
26
27
	public function endedSuccessfully() {
28
		$this->logger->debug( 'Entity imported' );
29
	}
30
31
	public function endedWithError( Exception $ex ) {
32
		$this->logger->error( $ex->getMessage() );
33
	}
34
35
	public function stepStarted( string $message ) {
36
		$this->logger->debug( 'Started step: ' . $message );
37
	}
38
39
	public function stepCompleted() {
40
		$this->logger->debug( 'Step completed' );
41
	}
42
43
}
44