Refactored project structure.

This commit is contained in:
Dmitry Khomutov 2018-03-04 18:04:15 +07:00
commit c015d8c58b
No known key found for this signature in database
GPG key ID: EC19426474B37AAC
308 changed files with 39 additions and 47 deletions

44
src/Plugin/Env.php Normal file
View file

@ -0,0 +1,44 @@
<?php
namespace PHPCensor\Plugin;
use PHPCensor\Plugin;
/**
* Environment variable plugin
*
* @author Steve Kamerman <stevekamerman@gmail.com>
*/
class Env extends Plugin
{
/**
* @return string
*/
public static function pluginName()
{
return 'env';
}
/**
* Adds the specified environment variables to the builder environment
*/
public function execute()
{
$success = true;
foreach ($this->options as $key => $value) {
if (is_numeric($key)) {
// This allows the developer to specify env vars like " - FOO=bar" or " - FOO: bar"
$envVar = is_array($value)? key($value).'='.current($value): $value;
} else {
// This allows the standard syntax: "FOO: bar"
$envVar = "$key=$value";
}
if (!putenv($this->builder->interpolate($envVar))) {
$success = false;
$this->builder->logFailure('Unable to set environment variable');
}
}
return $success;
}
}