diff --git a/src/Command/UpdateAllProjects.php b/src/Command/UpdateAllProjects.php index 92afd8a11dfa06b8e799c47e649a52c76acbba50..41d7c46298552527d0a9898932ecbf11f077179e 100644 --- a/src/Command/UpdateAllProjects.php +++ b/src/Command/UpdateAllProjects.php @@ -71,29 +71,27 @@ class UpdateAllProjects extends Command $legacy_root = $this->kernel->getProjectDir() . '/legacy'; $capsule_prototype_root = './capsule-prototype'; - $blackList = array( - 'css', 'create.zip', 'favicon.ico', 'la-page-des-malins.php', 'js', 'php', 'shared', '.', '..' - ); + $black_list = ['css', 'create.zip', 'favicon.ico', 'la-page-des-malins.php', 'js', 'php', 'shared', '.', '..']; $directory_files = scandir($legacy_root); if (false === $directory_files) { return Command::FAILURE; } - $all_file_in_directory = array_diff($directory_files, $blackList); + $all_file_in_directory = array_diff($directory_files, $black_list); - $phpFiles = glob($capsule_prototype_root . '/php/*.php'); + $php_files = glob($capsule_prototype_root . '/php/*.php'); // add +1 for index.html file - $phpFilesCountPerProjects = count($phpFiles ?: []) + 1; + $php_files_count_per_projects = count($php_files ?: []) + 1; - $allProjectsProgressBar = new ProgressBar($output->section()); - $allProjectsProgressBar->setFormat( + $all_projects_progress_bar = new ProgressBar($output->section()); + $all_projects_progress_bar->setFormat( '%current%/%max% [%bar%] %percent%% : Overall project update progressing (%elapsed%)' ); - $allProjectsProgressBar->SetMessage('Projects update progress'); - $allProjectsProgressBar->start(); + $all_projects_progress_bar->SetMessage('Projects update progress'); + $all_projects_progress_bar->start(); - foreach ($allProjectsProgressBar->iterate($all_file_in_directory) as $value) { + foreach ($all_projects_progress_bar->iterate($all_file_in_directory) as $value) { $current_legacy_path = Path::normalize($legacy_root . '/' . $value); if (!$this->filesystem->exists($current_legacy_path)) { @@ -104,15 +102,15 @@ class UpdateAllProjects extends Command continue; } - if (in_array($value, $blackList)) { + if (in_array($value, $black_list)) { continue; } - $progressBar = new ProgressBar($output->section(), $phpFilesCountPerProjects); - $progressBar->setFormat('project_update_message'); - $progressBar->setMessage($current_legacy_path, 'project'); + $progress_bar = new ProgressBar($output->section(), $php_files_count_per_projects); + $progress_bar->setFormat('project_update_message'); + $progress_bar->setMessage($current_legacy_path, 'project'); - $progressBar->start(); + $progress_bar->start(); // override index.html $this->filesystem->copy( @@ -120,7 +118,7 @@ class UpdateAllProjects extends Command Path::normalize($current_legacy_path . '/index.html'), true ); - $progressBar->advance(); + $progress_bar->advance(); // override php files $this->filesystem->mirror( @@ -129,23 +127,13 @@ class UpdateAllProjects extends Command null, ['override' => true, 'delete' => true ] ); - $progressBar->advance($phpFilesCountPerProjects - 1); - $progressBar->finish(); - $allProjectsProgressBar->advance($phpFilesCountPerProjects); + $progress_bar->advance($php_files_count_per_projects - 1); + $progress_bar->finish(); + $all_projects_progress_bar->advance($php_files_count_per_projects); } - $allProjectsProgressBar->finish(); + $all_projects_progress_bar->finish(); - // return this if there was no problem running the command - // (it's equivalent to returning int(0)) return Command::SUCCESS; - - // or return this if some error happened during the execution - // (it's equivalent to returning int(1)) - // return Command::FAILURE; - - // or return this to indicate incorrect command usage; e.g. invalid options - // or missing arguments (it's equivalent to returning int(2)) - // return Command::INVALID } }