Platform.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OC\App;
  8. use OCP\IBinaryFinder;
  9. use OCP\IConfig;
  10. /**
  11. * Class Platform
  12. *
  13. * This class basically abstracts any kind of information which can be retrieved from the underlying system.
  14. *
  15. * @package OC\App
  16. */
  17. class Platform {
  18. public function __construct(
  19. private IConfig $config,
  20. ) {
  21. }
  22. public function getPhpVersion(): string {
  23. return phpversion();
  24. }
  25. public function getIntSize(): int {
  26. return PHP_INT_SIZE;
  27. }
  28. public function getOcVersion(): string {
  29. $v = \OCP\Util::getVersion();
  30. return implode('.', $v);
  31. }
  32. public function getDatabase(): string {
  33. $dbType = $this->config->getSystemValueString('dbtype', 'sqlite');
  34. if ($dbType === 'sqlite3') {
  35. $dbType = 'sqlite';
  36. }
  37. return $dbType;
  38. }
  39. public function getOS(): string {
  40. return php_uname('s');
  41. }
  42. /**
  43. * @param $command
  44. */
  45. public function isCommandKnown(string $command): bool {
  46. return \OCP\Server::get(IBinaryFinder::class)->findBinaryPath($command) !== false;
  47. }
  48. public function getLibraryVersion(string $name): ?string {
  49. $repo = new PlatformRepository();
  50. return $repo->findLibrary($name);
  51. }
  52. public function getArchitecture(): string {
  53. return php_uname('m');
  54. }
  55. }