Skip to content

Commit 40bb41a

Browse files
committed
Refactor checks into single variable isJsonFormat
1 parent 022230c commit 40bb41a

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/Command/Process/ShowStatus.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class ShowStatus implements ProcessInterface
2828

2929
const FILTER_OPTION_ALL = 'All';
3030

31+
const FORMAT_JSON = 'json';
32+
3133
/**
3234
* @var Aggregator
3335
*/
@@ -103,31 +105,31 @@ public function __construct(
103105
*/
104106
public function run(InputInterface $input, OutputInterface $output)
105107
{
106-
if ($input->getOption('format') !== 'json') {
107-
$this->printDetailsInfo($output);
108-
$this->reviewAppliedAction->execute($input, $output, []);
109-
}
110-
111-
108+
$isJsonFormat = $input->getOption('format') === self::FORMAT_JSON;
112109
$patches = $this->aggregator->aggregate(
113110
array_merge($this->optionalPool->getList(), $this->localPool->getList())
114111
);
115112

116-
foreach ($patches as $patch) {
117-
if ($patch->isDeprecated() && $this->isPatchVisible($patch) && $input->getOption('format') !== 'json') {
118-
$this->printDeprecatedWarning($output, $patch);
113+
if (!$isJsonFormat) {
114+
$this->printDetailsInfo($output);
115+
$this->reviewAppliedAction->execute($input, $output, []);
116+
foreach ($patches as $patch) {
117+
if ($patch->isDeprecated() && $this->isPatchVisible($patch)) {
118+
$this->printDeprecatedWarning($output, $patch);
119+
}
119120
}
120121
}
122+
121123
$patches = $this->filterNotVisiblePatches($patches);
122124

123-
if (count($patches) > self::INTERACTIVE_FILTER_THRESHOLD) {
125+
if (!$isJsonFormat && count($patches) > self::INTERACTIVE_FILTER_THRESHOLD) {
124126
$this->printPatchProviders($output, $patches);
125127
$patches = $this->filterByPatchProvider($input, $output, $patches);
126128
$this->printCategoriesInfo($output, $patches);
127129
$patches = $this->filterByPatchCategory($input, $output, $patches);
128130
}
129131

130-
if ($input->getOption('format') === 'json') {
132+
if ($isJsonFormat) {
131133
$this->renderer->printJson($output, array_values($patches));
132134
} else {
133135
$this->renderer->printTable($output, array_values($patches));

0 commit comments

Comments
 (0)