DumpSqlCommand   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 4
dl 0
loc 34
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setDependencies() 0 4 1
A configure() 0 4 1
A execute() 0 5 2
A getQueries() 0 4 1
1
<?php
2
3
namespace Wikibase\QueryEngine\Console;
4
5
use Doctrine\DBAL\Platforms\AbstractPlatform;
6
use Doctrine\DBAL\Schema\Schema;
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
use Wikibase\QueryEngine\SQLStore\StoreSchema;
11
12
/**
13
 * @licence GNU GPL v2+
14
 * @author Jeroen De Dauw < [email protected] >
15
 */
16
class DumpSqlCommand extends Command {
17
18
	/**
19
	 * @var StoreSchema
20
	 */
21
	private $storeSchema;
22
23
	/**
24
	 * @var AbstractPlatform
25
	 */
26
	private $platform;
27
28
	public function setDependencies( StoreSchema $storeSchema, AbstractPlatform $platform ) {
29
		$this->storeSchema = $storeSchema;
30
		$this->platform = $platform;
31
	}
32
33
	protected function configure() {
34
		$this->setName( 'dump-sql' );
35
		$this->setDescription( 'Dumps the SQL for creating the QueryEngine SQL store schema' );
36
	}
37
38
	protected function execute( InputInterface $input, OutputInterface $output ) {
39
		foreach ( $this->getQueries() as $query ) {
40
			$output->writeln( $query );
41
		}
42
	}
43
44
	private function getQueries() {
45
		$schema = new Schema( $this->storeSchema->getTables() );
46
		return $schema->toSql( $this->platform );
47
	}
48
49
}
50