1<?php
2/**
3 * @author Lukas Reschke <lukas@statuscode.ch>
4 *
5 * @copyright Copyright (c) 2018, ownCloud GmbH
6 * @license AGPL-3.0
7 *
8 * This code is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License, version 3,
10 * as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
16 *
17 * You should have received a copy of the GNU Affero General Public License, version 3,
18 * along with this program.  If not, see <http://www.gnu.org/licenses/>
19 *
20 */
21
22namespace OC\IntegrityCheck\Helpers;
23
24/**
25 * Class AppLocator provides a non-static helper for OC_App::getPath($appId)
26 * it is not possible to use IAppManager at this point as IAppManager has a
27 * dependency on a running ownCloud.
28 *
29 * @package OC\IntegrityCheck\Helpers
30 */
31class AppLocator {
32	/**
33	 * Provides \OC_App::getAppPath($appId)
34	 *
35	 * @param string $appId
36	 * @return string
37	 * @throws \Exception If the app cannot be found
38	 */
39	public function getAppPath($appId) {
40		$path = \OC_App::getAppPath($appId);
41		if ($path === false) {
42			throw new \Exception('App not found');
43		}
44		return $path;
45	}
46
47	/**
48	 * Providers \OC_App::getAllApps()
49	 *
50	 * @return array
51	 */
52	public function getAllApps() {
53		return \OC_App::getAllApps();
54	}
55}
56