PhpMemoryLimit.php 970 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Settings\SetupChecks;
  8. use OC\MemoryInfo;
  9. use OCP\IL10N;
  10. use OCP\SetupCheck\ISetupCheck;
  11. use OCP\SetupCheck\SetupResult;
  12. use OCP\Util;
  13. class PhpMemoryLimit implements ISetupCheck {
  14. public function __construct(
  15. private IL10N $l10n,
  16. private MemoryInfo $memoryInfo,
  17. ) {
  18. }
  19. public function getCategory(): string {
  20. return 'php';
  21. }
  22. public function getName(): string {
  23. return $this->l10n->t('PHP memory limit');
  24. }
  25. public function run(): SetupResult {
  26. if ($this->memoryInfo->isMemoryLimitSufficient()) {
  27. return SetupResult::success(Util::humanFileSize($this->memoryInfo->getMemoryLimit()));
  28. } else {
  29. return SetupResult::error($this->l10n->t('The PHP memory limit is below the recommended value of %s.', Util::humanFileSize(MemoryInfo::RECOMMENDED_MEMORY_LIMIT)));
  30. }
  31. }
  32. }