Completed
Push — master ( d01339...b9998b )
by Jeroen De
02:51
created

ImportCommandBase   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 1
cbo 3
dl 0
loc 29
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setServiceFactory() 0 3 1
A execute() 0 14 3
executeCommand() 0 1 ?
1
<?php
2
3
namespace Queryr\Replicator\Cli\Command;
4
5
use Queryr\Replicator\ServiceFactory;
6
use RuntimeException;
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
/**
12
 * @licence GNU GPL v2+
13
 * @author Jeroen De Dauw < [email protected] >
14
 */
15
abstract class ImportCommandBase extends Command {
16
17
	/**
18
	 * @var ServiceFactory|null
19
	 */
20
	protected $factory = null;
21
22
	public function setServiceFactory( ServiceFactory $factory ) {
23
		$this->factory = $factory;
24
	}
25
26
	final protected function execute( InputInterface $input, OutputInterface $output ) {
27
		if ( $this->factory === null ) {
28
			try {
29
				$this->factory = ServiceFactory::newFromConfig();
0 ignored issues
show
Documentation Bug introduced by
It seems like \Queryr\Replicator\ServiceFactory::newFromConfig() of type object<self> is incompatible with the declared type object<Queryr\Replicator\ServiceFactory>|null of property $factory.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
30
			}
31
			catch ( RuntimeException $ex ) {
32
				$output->writeln( '<error>Could not instantiate the Replicator app</error>' );
33
				$output->writeln( '<error>' . $ex->getMessage() . '</error>' );
34
				return;
35
			}
36
		}
37
38
		$this->executeCommand( $input, $output );
39
	}
40
41
	abstract protected function executeCommand( InputInterface $input, OutputInterface $output );
42
43
}
44