Platform.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 OC_Util;
  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. 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 join('.', $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. $lib = $repo->findLibrary($name);
  87. return $lib;
  88. }
  89. }