Passed
Push — master ( 7e229a...87105a )
by Julius
25:22 queued 12:41
created
core/Command/App/ListApps.php 2 patches
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -33,106 +33,106 @@
 block discarded – undo
33 33
 use Symfony\Component\Console\Output\OutputInterface;
34 34
 
35 35
 class ListApps extends Base {
36
-	protected IAppManager $manager;
37
-
38
-	public function __construct(IAppManager $manager) {
39
-		parent::__construct();
40
-		$this->manager = $manager;
41
-	}
42
-
43
-	protected function configure() {
44
-		parent::configure();
45
-
46
-		$this
47
-			->setName('app:list')
48
-			->setDescription('List all available apps')
49
-			->addOption(
50
-				'shipped',
51
-				null,
52
-				InputOption::VALUE_REQUIRED,
53
-				'true - limit to shipped apps only, false - limit to non-shipped apps only'
54
-			)
55
-		;
56
-	}
57
-
58
-	protected function execute(InputInterface $input, OutputInterface $output): int {
59
-		if ($input->getOption('shipped') === 'true' || $input->getOption('shipped') === 'false') {
60
-			$shippedFilter = $input->getOption('shipped') === 'true';
61
-		} else {
62
-			$shippedFilter = null;
63
-		}
64
-
65
-		$apps = \OC_App::getAllApps();
66
-		$enabledApps = $disabledApps = [];
67
-		$versions = \OC_App::getAppVersions();
68
-
69
-		//sort enabled apps above disabled apps
70
-		foreach ($apps as $app) {
71
-			if ($shippedFilter !== null && $this->manager->isShipped($app) !== $shippedFilter) {
72
-				continue;
73
-			}
74
-			if ($this->manager->isInstalled($app)) {
75
-				$enabledApps[] = $app;
76
-			} else {
77
-				$disabledApps[] = $app;
78
-			}
79
-		}
80
-
81
-		$apps = ['enabled' => [], 'disabled' => []];
82
-
83
-		sort($enabledApps);
84
-		foreach ($enabledApps as $app) {
85
-			$apps['enabled'][$app] = $versions[$app] ?? true;
86
-		}
87
-
88
-		sort($disabledApps);
89
-		foreach ($disabledApps as $app) {
90
-			$apps['disabled'][$app] = $this->manager->getAppVersion($app) . (isset($versions[$app]) ? ' (installed ' . $versions[$app] . ')' : '');
91
-		}
92
-
93
-		$this->writeAppList($input, $output, $apps);
94
-		return 0;
95
-	}
96
-
97
-	/**
98
-	 * @param InputInterface $input
99
-	 * @param OutputInterface $output
100
-	 * @param array $items
101
-	 */
102
-	protected function writeAppList(InputInterface $input, OutputInterface $output, $items) {
103
-		switch ($input->getOption('output')) {
104
-			case self::OUTPUT_FORMAT_PLAIN:
105
-				$output->writeln('Enabled:');
106
-				parent::writeArrayInOutputFormat($input, $output, $items['enabled']);
107
-
108
-				$output->writeln('Disabled:');
109
-				parent::writeArrayInOutputFormat($input, $output, $items['disabled']);
110
-			break;
111
-
112
-			default:
113
-				parent::writeArrayInOutputFormat($input, $output, $items);
114
-			break;
115
-		}
116
-	}
117
-
118
-	/**
119
-	 * @param string $optionName
120
-	 * @param CompletionContext $context
121
-	 * @return array
122
-	 */
123
-	public function completeOptionValues($optionName, CompletionContext $context) {
124
-		if ($optionName === 'shipped') {
125
-			return ['true', 'false'];
126
-		}
127
-		return [];
128
-	}
129
-
130
-	/**
131
-	 * @param string $argumentName
132
-	 * @param CompletionContext $context
133
-	 * @return string[]
134
-	 */
135
-	public function completeArgumentValues($argumentName, CompletionContext $context) {
136
-		return [];
137
-	}
36
+    protected IAppManager $manager;
37
+
38
+    public function __construct(IAppManager $manager) {
39
+        parent::__construct();
40
+        $this->manager = $manager;
41
+    }
42
+
43
+    protected function configure() {
44
+        parent::configure();
45
+
46
+        $this
47
+            ->setName('app:list')
48
+            ->setDescription('List all available apps')
49
+            ->addOption(
50
+                'shipped',
51
+                null,
52
+                InputOption::VALUE_REQUIRED,
53
+                'true - limit to shipped apps only, false - limit to non-shipped apps only'
54
+            )
55
+        ;
56
+    }
57
+
58
+    protected function execute(InputInterface $input, OutputInterface $output): int {
59
+        if ($input->getOption('shipped') === 'true' || $input->getOption('shipped') === 'false') {
60
+            $shippedFilter = $input->getOption('shipped') === 'true';
61
+        } else {
62
+            $shippedFilter = null;
63
+        }
64
+
65
+        $apps = \OC_App::getAllApps();
66
+        $enabledApps = $disabledApps = [];
67
+        $versions = \OC_App::getAppVersions();
68
+
69
+        //sort enabled apps above disabled apps
70
+        foreach ($apps as $app) {
71
+            if ($shippedFilter !== null && $this->manager->isShipped($app) !== $shippedFilter) {
72
+                continue;
73
+            }
74
+            if ($this->manager->isInstalled($app)) {
75
+                $enabledApps[] = $app;
76
+            } else {
77
+                $disabledApps[] = $app;
78
+            }
79
+        }
80
+
81
+        $apps = ['enabled' => [], 'disabled' => []];
82
+
83
+        sort($enabledApps);
84
+        foreach ($enabledApps as $app) {
85
+            $apps['enabled'][$app] = $versions[$app] ?? true;
86
+        }
87
+
88
+        sort($disabledApps);
89
+        foreach ($disabledApps as $app) {
90
+            $apps['disabled'][$app] = $this->manager->getAppVersion($app) . (isset($versions[$app]) ? ' (installed ' . $versions[$app] . ')' : '');
91
+        }
92
+
93
+        $this->writeAppList($input, $output, $apps);
94
+        return 0;
95
+    }
96
+
97
+    /**
98
+     * @param InputInterface $input
99
+     * @param OutputInterface $output
100
+     * @param array $items
101
+     */
102
+    protected function writeAppList(InputInterface $input, OutputInterface $output, $items) {
103
+        switch ($input->getOption('output')) {
104
+            case self::OUTPUT_FORMAT_PLAIN:
105
+                $output->writeln('Enabled:');
106
+                parent::writeArrayInOutputFormat($input, $output, $items['enabled']);
107
+
108
+                $output->writeln('Disabled:');
109
+                parent::writeArrayInOutputFormat($input, $output, $items['disabled']);
110
+            break;
111
+
112
+            default:
113
+                parent::writeArrayInOutputFormat($input, $output, $items);
114
+            break;
115
+        }
116
+    }
117
+
118
+    /**
119
+     * @param string $optionName
120
+     * @param CompletionContext $context
121
+     * @return array
122
+     */
123
+    public function completeOptionValues($optionName, CompletionContext $context) {
124
+        if ($optionName === 'shipped') {
125
+            return ['true', 'false'];
126
+        }
127
+        return [];
128
+    }
129
+
130
+    /**
131
+     * @param string $argumentName
132
+     * @param CompletionContext $context
133
+     * @return string[]
134
+     */
135
+    public function completeArgumentValues($argumentName, CompletionContext $context) {
136
+        return [];
137
+    }
138 138
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@
 block discarded – undo
87 87
 
88 88
 		sort($disabledApps);
89 89
 		foreach ($disabledApps as $app) {
90
-			$apps['disabled'][$app] = $this->manager->getAppVersion($app) . (isset($versions[$app]) ? ' (installed ' . $versions[$app] . ')' : '');
90
+			$apps['disabled'][$app] = $this->manager->getAppVersion($app).(isset($versions[$app]) ? ' (installed '.$versions[$app].')' : '');
91 91
 		}
92 92
 
93 93
 		$this->writeAppList($input, $output, $apps);
Please login to merge, or discard this patch.