Refactored plugins

This commit is contained in:
Dmitry Khomutov 2016-07-11 22:00:04 +06:00
commit 16a5add859
45 changed files with 404 additions and 1224 deletions

View file

@ -20,34 +20,17 @@ use PHPCensor\Plugin;
* @package PHPCI
* @subpackage Plugins
*/
class Env implements Plugin
class Env extends Plugin
{
protected $phpci;
protected $build;
protected $env_vars;
/**
* Set up the plugin, configure options, etc.
* @param Builder $phpci
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
$this->env_vars = $options;
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**
* Adds the specified environment variables to the builder environment
*/
public function execute()
{
$success = true;
foreach ($this->env_vars as $key => $value) {
foreach ($this->options as $key => $value) {
if (is_numeric($key)) {
// This allows the developer to specify env vars like " - FOO=bar" or " - FOO: bar"
$env_var = is_array($value)? key($value).'='.current($value): $value;