Completed
Push — master ( 1f63e8...5f9700 )
by Lukas
13:32
created

Platform::getIntSize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * @author Morris Jobke <[email protected]>
4
 * @author Thomas Müller <[email protected]>
5
 *
6
 * @copyright Copyright (c) 2016, ownCloud, Inc.
7
 * @license AGPL-3.0
8
 *
9
 * This code is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Affero General Public License, version 3,
11
 * as published by the Free Software Foundation.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
 * GNU Affero General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Affero General Public License, version 3,
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
20
 *
21
 */
22
23
namespace OC\App;
24
25
use OC_Util;
26
use OCP\IConfig;
27
28
/**
29
 * Class Platform
30
 *
31
 * This class basically abstracts any kind of information which can be retrieved from the underlying system.
32
 *
33
 * @package OC\App
34
 */
35
class Platform {
36
37
	/**
38
	 * @param IConfig $config
39
	 */
40
	function __construct(IConfig $config) {
41
		$this->config = $config;
0 ignored issues
show
Bug introduced by
The property config does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
42
	}
43
44
	/**
45
	 * @return string
46
	 */
47
	public function getPhpVersion() {
48
		return phpversion();
49
	}
50
51
	/**
52
	 * @return int
53
	 */
54
	public function getIntSize() {
55
		return PHP_INT_SIZE;
56
	}
57
58
	/**
59
	 * @return string
60
	 */
61
	public function getOcVersion() {
62
		$v = \OCP\Util::getVersion();
63
		return join('.', $v);
64
	}
65
66
	/**
67
	 * @return string
68
	 */
69
	public function getDatabase() {
70
		$dbType = $this->config->getSystemValue('dbtype', 'sqlite');
71
		if ($dbType === 'sqlite3') {
72
			$dbType = 'sqlite';
73
		}
74
75
		return $dbType;
76
	}
77
78
	/**
79
	 * @return string
80
	 */
81
	public function getOS() {
82
		return php_uname('s');
83
	}
84
85
	/**
86
	 * @param $command
87
	 * @return bool
88
	 */
89
	public function isCommandKnown($command) {
90
		$path = \OC_Helper::findBinaryPath($command);
91
		return ($path !== null);
92
	}
93
94
	public function getLibraryVersion($name) {
95
		$repo = new PlatformRepository();
96
		$lib = $repo->findLibrary($name);
97
		return $lib;
98
	}
99
}
100