Platform.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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\IConfig;
  28. use OCP\IBinaryFinder;
  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. private IConfig $config;
  38. public function __construct(IConfig $config) {
  39. $this->config = $config;
  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. }