Passed
Push — master ( c9639f...ec07ca )
by Morris
24:32 queued 11:33
created

Platform::getDatabase()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @copyright Copyright (c) 2016, ownCloud, Inc.
4
 *
5
 * @author Bernhard Posselt <[email protected]>
6
 * @author Christoph Wurst <[email protected]>
7
 * @author Morris Jobke <[email protected]>
8
 * @author Thomas Müller <[email protected]>
9
 *
10
 * @license AGPL-3.0
11
 *
12
 * This code is free software: you can redistribute it and/or modify
13
 * it under the terms of the GNU Affero General Public License, version 3,
14
 * as published by the Free Software Foundation.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
 * GNU Affero General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU Affero General Public License, version 3,
22
 * along with this program. If not, see <http://www.gnu.org/licenses/>
23
 *
24
 */
25
26
namespace OC\App;
27
28
use OCP\IConfig;
29
30
/**
31
 * Class Platform
32
 *
33
 * This class basically abstracts any kind of information which can be retrieved from the underlying system.
34
 *
35
 * @package OC\App
36
 */
37
class Platform {
38
39
	/**
40
	 * @param IConfig $config
41
	 */
42
	public function __construct(IConfig $config) {
43
		$this->config = $config;
0 ignored issues
show
Bug Best Practice introduced by
The property config does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
44
	}
45
46
	/**
47
	 * @return string
48
	 */
49
	public function getPhpVersion() {
50
		return phpversion();
51
	}
52
53
	/**
54
	 * @return int
55
	 */
56
	public function getIntSize() {
57
		return PHP_INT_SIZE;
58
	}
59
60
	/**
61
	 * @return string
62
	 */
63
	public function getOcVersion() {
64
		$v = \OCP\Util::getVersion();
65
		return implode('.', $v);
66
	}
67
68
	/**
69
	 * @return string
70
	 */
71
	public function getDatabase() {
72
		$dbType = $this->config->getSystemValue('dbtype', 'sqlite');
73
		if ($dbType === 'sqlite3') {
74
			$dbType = 'sqlite';
75
		}
76
77
		return $dbType;
78
	}
79
80
	/**
81
	 * @return string
82
	 */
83
	public function getOS() {
84
		return php_uname('s');
85
	}
86
87
	/**
88
	 * @param $command
89
	 * @return bool
90
	 */
91
	public function isCommandKnown($command) {
92
		$path = \OC_Helper::findBinaryPath($command);
93
		return ($path !== null);
94
	}
95
96
	public function getLibraryVersion($name) {
97
		$repo = new PlatformRepository();
98
		return $repo->findLibrary($name);
99
	}
100
101
	public function getArchitecture(): string {
102
		return php_uname('m');
103
	}
104
}
105