Platform.php 2.0 KB

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