CliImportReporter::onEntityInsertFailed()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace Wikibase\QueryEngine\Console\Import;
4
5
use Exception;
6
use Symfony\Component\Console\Output\OutputInterface;
7
use Wikibase\DataModel\Entity\EntityDocument;
8
use Wikibase\QueryEngine\Importer\ImportReporter;
9
10
/**
11
 * @since 0.3
12
 * @licence GNU GPL v2+
13
 * @author Jeroen De Dauw < [email protected] >
14
 */
15
class CliImportReporter implements ImportReporter {
16
17
	private $output;
18
19
	public function __construct( OutputInterface $output ) {
20
		$this->output = $output;
21
	}
22
23
	public function onImportStarted() {
24
		$this->output->writeln( '<info>Started import</info>' );
25
	}
26
27
	public function onEntityInsertStarted( EntityDocument $entity ) {
28
		$this->output->write( '<info>Importing ' . $entity->getId()->getSerialization() . '... </info>' );
29
	}
30
31
	public function onEntityInsertSucceeded( EntityDocument $entity ) {
32
		$this->output->writeln( '<info>done.</info>' );
33
	}
34
35
	public function onEntityInsertFailed( EntityDocument $entity, Exception $ex ) {
36
		$this->output->writeln( '<info>failed!</info>' );
37
		$this->output->writeln( '<error>' . $ex->getMessage() . '</error>' );
38
	}
39
40
	public function onImportCompleted() {
41
		$this->output->writeln( '<info>Completed import</info>' );
42
	}
43
44
	public function onImportAborted() {
45
		$this->output->writeln( '<info>Aborted import</info>' );
46
	}
47
48
}
49