1
0

Platform.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 Julius Härtl <jus@bitgrid.net>
  8. * @author Morris Jobke <hey@morrisjobke.de>
  9. * @author Thomas Müller <thomas.mueller@tmit.eu>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. namespace OC\App;
  27. use OCP\IBinaryFinder;
  28. use OCP\IConfig;
  29. /**
  30. * Class Platform
  31. *
  32. * This class basically abstracts any kind of information which can be retrieved from the underlying system.
  33. *
  34. * @package OC\App
  35. */
  36. class Platform {
  37. public function __construct(
  38. private IConfig $config,
  39. ) {
  40. }
  41. public function getPhpVersion(): string {
  42. return phpversion();
  43. }
  44. public function getIntSize(): int {
  45. return PHP_INT_SIZE;
  46. }
  47. public function getOcVersion(): string {
  48. $v = \OCP\Util::getVersion();
  49. return implode('.', $v);
  50. }
  51. public function getDatabase(): string {
  52. $dbType = $this->config->getSystemValueString('dbtype', 'sqlite');
  53. if ($dbType === 'sqlite3') {
  54. $dbType = 'sqlite';
  55. }
  56. return $dbType;
  57. }
  58. public function getOS(): string {
  59. return php_uname('s');
  60. }
  61. /**
  62. * @param $command
  63. */
  64. public function isCommandKnown(string $command): bool {
  65. return \OCP\Server::get(IBinaryFinder::class)->findBinaryPath($command) !== false;
  66. }
  67. public function getLibraryVersion(string $name): ?string {
  68. $repo = new PlatformRepository();
  69. return $repo->findLibrary($name);
  70. }
  71. public function getArchitecture(): string {
  72. return php_uname('m');
  73. }
  74. }