Code style fixes (camelCased variables).
This commit is contained in:
parent
4013fc76ff
commit
8d9c4824c7
15 changed files with 141 additions and 142 deletions
|
|
@ -756,27 +756,27 @@ class Build extends Model
|
|||
*/
|
||||
protected function handleConfig(Builder $builder, $buildPath)
|
||||
{
|
||||
$build_config = $this->getProject()->getBuildConfig();
|
||||
$buildConfig = $this->getProject()->getBuildConfig();
|
||||
|
||||
if (empty($build_config)) {
|
||||
if (empty($buildConfig)) {
|
||||
if (file_exists($buildPath . '/.php-censor.yml')) {
|
||||
$build_config = file_get_contents($buildPath . '/.php-censor.yml');
|
||||
$buildConfig = file_get_contents($buildPath . '/.php-censor.yml');
|
||||
} elseif (file_exists($buildPath . '/.phpci.yml')) {
|
||||
$build_config = file_get_contents($buildPath . '/.phpci.yml');
|
||||
$buildConfig = file_get_contents($buildPath . '/.phpci.yml');
|
||||
} elseif (file_exists($buildPath . '/phpci.yml')) {
|
||||
$build_config = file_get_contents($buildPath . '/phpci.yml');
|
||||
$buildConfig = file_get_contents($buildPath . '/phpci.yml');
|
||||
} else {
|
||||
$build_config = $this->getZeroConfigPlugins($builder);
|
||||
$buildConfig = $this->getZeroConfigPlugins($builder);
|
||||
}
|
||||
}
|
||||
|
||||
// for YAML configs from files/DB
|
||||
if (is_string($build_config)) {
|
||||
if (is_string($buildConfig)) {
|
||||
$yamlParser = new YamlParser();
|
||||
$build_config = $yamlParser->parse($build_config);
|
||||
$buildConfig = $yamlParser->parse($buildConfig);
|
||||
}
|
||||
|
||||
$builder->setConfigArray($build_config);
|
||||
$builder->setConfigArray($buildConfig);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -989,11 +989,11 @@ class Build extends Model
|
|||
$end = new \DateTime();
|
||||
}
|
||||
|
||||
$diff = date_diff($start, $end);
|
||||
$diff = date_diff($start, $end);
|
||||
$parts = [];
|
||||
foreach (['y', 'm', 'd', 'h', 'i', 's'] as $time_part) {
|
||||
if ($diff->{$time_part} != 0) {
|
||||
$parts[] = $diff->{$time_part} . ($time_part == 'i' ? 'm' : $time_part);
|
||||
foreach (['y', 'm', 'd', 'h', 'i', 's'] as $timePart) {
|
||||
if ($diff->{$timePart} != 0) {
|
||||
$parts[] = $diff->{$timePart} . ($timePart == 'i' ? 'm' : $timePart);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -702,14 +702,14 @@ class Project extends Model
|
|||
*/
|
||||
public function getEnvironmentsNames()
|
||||
{
|
||||
$environments = $this->getEnvironmentsObjects();
|
||||
$environments_names = [];
|
||||
$environments = $this->getEnvironmentsObjects();
|
||||
$environmentsNames = [];
|
||||
foreach($environments['items'] as $environment) {
|
||||
/** @var Environment $environment */
|
||||
$environments_names[] = $environment->getName();
|
||||
$environmentsNames[] = $environment->getName();
|
||||
}
|
||||
|
||||
return $environments_names;
|
||||
return $environmentsNames;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -719,15 +719,15 @@ class Project extends Model
|
|||
*/
|
||||
public function getEnvironments()
|
||||
{
|
||||
$environments = $this->getEnvironmentsObjects();
|
||||
$environments_config = [];
|
||||
$environments = $this->getEnvironmentsObjects();
|
||||
$environmentsConfig = [];
|
||||
foreach($environments['items'] as $environment) {
|
||||
/** @var Environment $environment */
|
||||
$environments_config[$environment->getName()] = $environment->getBranches();
|
||||
$environmentsConfig[$environment->getName()] = $environment->getBranches();
|
||||
}
|
||||
|
||||
$yaml_dumper = new YamlDumper();
|
||||
$value = $yaml_dumper->dump($environments_config, 10, 0, true, false);
|
||||
$yamlDumper = new YamlDumper();
|
||||
$value = $yamlDumper->dump($environmentsConfig, 10, 0, true, false);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
|
@ -739,18 +739,18 @@ class Project extends Model
|
|||
*/
|
||||
public function setEnvironments($value)
|
||||
{
|
||||
$yaml_parser = new YamlParser();
|
||||
$environments_config = $yaml_parser->parse($value);
|
||||
$environments_names = !empty($environments_config) ? array_keys($environments_config) : [];
|
||||
$current_environments = $this->getEnvironmentsObjects();
|
||||
$store = $this->getEnvironmentStore();
|
||||
foreach ($current_environments['items'] as $environment) {
|
||||
$yamlParser = new YamlParser();
|
||||
$environmentsConfig = $yamlParser->parse($value);
|
||||
$environmentsNames = !empty($environmentsConfig) ? array_keys($environmentsConfig) : [];
|
||||
$currentEnvironments = $this->getEnvironmentsObjects();
|
||||
$store = $this->getEnvironmentStore();
|
||||
foreach ($currentEnvironments['items'] as $environment) {
|
||||
/** @var Environment $environment */
|
||||
$key = array_search($environment->getName(), $environments_names);
|
||||
$key = array_search($environment->getName(), $environmentsNames);
|
||||
if ($key !== false) {
|
||||
// already exist
|
||||
unset($environments_names[$key]);
|
||||
$environment->setBranches(!empty($environments_config[$environment->getName()]) ? $environments_config[$environment->getName()] : []);
|
||||
unset($environmentsNames[$key]);
|
||||
$environment->setBranches(!empty($environmentsConfig[$environment->getName()]) ? $environmentsConfig[$environment->getName()] : []);
|
||||
$store->save($environment);
|
||||
} else {
|
||||
// remove
|
||||
|
|
@ -758,13 +758,13 @@ class Project extends Model
|
|||
}
|
||||
}
|
||||
|
||||
if (!empty($environments_names)) {
|
||||
if (!empty($environmentsNames)) {
|
||||
// add
|
||||
foreach ($environments_names as $environment_name) {
|
||||
foreach ($environmentsNames as $environmentName) {
|
||||
$environment = new Environment();
|
||||
$environment->setProjectId($this->getId());
|
||||
$environment->setName($environment_name);
|
||||
$environment->setBranches(!empty($environments_config[$environment->getName()]) ? $environments_config[$environment->getName()] : []);
|
||||
$environment->setName($environmentName);
|
||||
$environment->setBranches(!empty($environmentsConfig[$environment->getName()]) ? $environmentsConfig[$environment->getName()] : []);
|
||||
$store->save($environment);
|
||||
}
|
||||
}
|
||||
|
|
@ -777,31 +777,31 @@ class Project extends Model
|
|||
*/
|
||||
public function getEnvironmentsNamesByBranch($branch)
|
||||
{
|
||||
$environments_names = [];
|
||||
$environments = $this->getEnvironmentsObjects();
|
||||
$default_branch = ($branch == $this->getBranch());
|
||||
$environmentsNames = [];
|
||||
$environments = $this->getEnvironmentsObjects();
|
||||
$defaultBranch = ($branch == $this->getBranch());
|
||||
foreach($environments['items'] as $environment) {
|
||||
/** @var Environment $environment */
|
||||
if ($default_branch || in_array($branch, $environment->getBranches())) {
|
||||
$environments_names[] = $environment->getName();
|
||||
if ($defaultBranch || in_array($branch, $environment->getBranches())) {
|
||||
$environmentsNames[] = $environment->getName();
|
||||
}
|
||||
}
|
||||
|
||||
return $environments_names;
|
||||
return $environmentsNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $environment_name
|
||||
* @param string $environmentName
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getBranchesByEnvironment($environment_name)
|
||||
public function getBranchesByEnvironment($environmentName)
|
||||
{
|
||||
$branches = [];
|
||||
$environments = $this->getEnvironmentsObjects();
|
||||
foreach($environments['items'] as $environment) {
|
||||
/** @var Environment $environment */
|
||||
if ($environment_name == $environment->getName()) {
|
||||
if ($environmentName == $environment->getName()) {
|
||||
return $environment->getBranches();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue