Reduced cyclomatic complexity

This commit is contained in:
Pavel Pavlov 2013-10-17 14:51:20 +04:00
parent 2c1c5bfbe9
commit d214c9dc0e

View file

@ -23,23 +23,42 @@ class Phing implements \PHPCI\Plugin
{ {
private $directory; private $directory;
private $buildFile; private $buildFile = 'build.xml';
private $targets; private $targets = array('build');
private $properties; private $properties = array();
private $propertyFile; private $propertyFile;
protected $phpci; protected $phpci;
public function __construct(Builder $phpci, Build $build, array $options = array()) public function __construct(Builder $phpci, Build $build, array $options = array())
{ {
$this $this->setPhpci($phpci);
->setDirectory(
isset($options['directory']) ? $phpci->buildPath . '/' . $options['directory'] : $phpci->buildPath /*
) * Set working directory
->setPhpci($phpci) */
->setBuildFile(isset($options['build_file']) ? $options['build_file'] : 'build.xml') if (isset($options['directory'])) {
->setTargets(isset($options['targets']) ? $options['targets'] : 'build') $directory = $phpci->buildPath . '/' . $options['directory'];
->setProperties(isset($options['properties']) ? $options['properties'] : []); } else {
$directory = $phpci->buildPath;
}
$this->setDirectory($directory);
/*
* Sen name of a non default build file
*/
if (isset($options['build_file'])) {
$this->setBuildFile($options['build_file']);
}
if (isset($options['targets'])) {
$this->setTargets($options['targets']);
}
if (isset($options['properties'])) {
$this->setProperties($options['properties']);
}
if (isset($options['property_file'])) { if (isset($options['property_file'])) {
$this->setPropertyFile($options['property_file']); $this->setPropertyFile($options['property_file']);
@ -58,7 +77,7 @@ class Phing implements \PHPCI\Plugin
return false; return false;
} }
$cmd[] = $phingExecutable . ' -f ' . $this->getBuildFile(); $cmd[] = $phingExecutable . ' -f ' . $this->getBuildFilePath();
if ($this->getPropertyFile()) { if ($this->getPropertyFile()) {
$cmd[] = '-propertyfile ' . $this->getPropertyFile(); $cmd[] = '-propertyfile ' . $this->getPropertyFile();
@ -89,7 +108,6 @@ class Phing implements \PHPCI\Plugin
public function setPhpci($phpci) public function setPhpci($phpci)
{ {
$this->phpci = $phpci; $this->phpci = $phpci;
return $this;
} }
/** /**
@ -108,7 +126,6 @@ class Phing implements \PHPCI\Plugin
public function setDirectory($directory) public function setDirectory($directory)
{ {
$this->directory = $directory; $this->directory = $directory;
return $this;
} }
/** /**
@ -136,7 +153,6 @@ class Phing implements \PHPCI\Plugin
} }
$this->targets = $targets; $this->targets = $targets;
return $this;
} }
/** /**
@ -155,13 +171,16 @@ class Phing implements \PHPCI\Plugin
*/ */
public function setBuildFile($buildFile) public function setBuildFile($buildFile)
{ {
$buildFile = $this->getDirectory() . $buildFile; if (!file_exists($this->getDirectory() . $buildFile)) {
if (!file_exists($buildFile)) {
throw new \Exception('Specified build file does not exists.'); throw new \Exception('Specified build file does not exists.');
} }
$this->buildFile = $buildFile; $this->buildFile = $buildFile;
return $this; }
public function getBuildFilePath()
{
return $this->getDirectory() . $this->buildFile;
} }
/** /**
@ -202,7 +221,6 @@ class Phing implements \PHPCI\Plugin
} }
$this->properties = $properties; $this->properties = $properties;
return $this;
} }
/** /**
@ -226,6 +244,5 @@ class Phing implements \PHPCI\Plugin
} }
$this->propertyFile = $propertyFile; $this->propertyFile = $propertyFile;
return $this;
} }
} }