You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
2.2 KiB

3 years ago
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bernhard Posselt <dev@bernhard-posselt.com>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Morris Jobke <hey@morrisjobke.de>
  8. * @author Thomas Müller <thomas.mueller@tmit.eu>
  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. namespace OC\App;
  26. use OCP\IConfig;
  27. /**
  28. * Class Platform
  29. *
  30. * This class basically abstracts any kind of information which can be retrieved from the underlying system.
  31. *
  32. * @package OC\App
  33. */
  34. class Platform {
  35. /**
  36. * @param IConfig $config
  37. */
  38. public function __construct(IConfig $config) {
  39. $this->config = $config;
  40. }
  41. /**
  42. * @return string
  43. */
  44. public function getPhpVersion() {
  45. return phpversion();
  46. }
  47. /**
  48. * @return int
  49. */
  50. public function getIntSize() {
  51. return PHP_INT_SIZE;
  52. }
  53. /**
  54. * @return string
  55. */
  56. public function getOcVersion() {
  57. $v = \OCP\Util::getVersion();
  58. return implode('.', $v);
  59. }
  60. /**
  61. * @return string
  62. */
  63. public function getDatabase() {
  64. $dbType = $this->config->getSystemValue('dbtype', 'sqlite');
  65. if ($dbType === 'sqlite3') {
  66. $dbType = 'sqlite';
  67. }
  68. return $dbType;
  69. }
  70. /**
  71. * @return string
  72. */
  73. public function getOS() {
  74. return php_uname('s');
  75. }
  76. /**
  77. * @param $command
  78. * @return bool
  79. */
  80. public function isCommandKnown($command) {
  81. $path = \OC_Helper::findBinaryPath($command);
  82. return ($path !== null);
  83. }
  84. public function getLibraryVersion($name) {
  85. $repo = new PlatformRepository();
  86. return $repo->findLibrary($name);
  87. }
  88. public function getArchitecture(): string {
  89. return php_uname('m');
  90. }
  91. }