Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Helper.php

function Helper::formatMemory

2 calls to Helper::formatMemory()
ProgressBar::initPlaceholderFormatters in vendor/symfony/console/Helper/ProgressBar.php
ProgressIndicator::initPlaceholderFormatters in vendor/symfony/console/Helper/ProgressIndicator.php

File

vendor/symfony/console/Helper/Helper.php, line 128

Class

Helper
Helper is the base class for all helper classes.

Namespace

Symfony\Component\Console\Helper

Code

public static function formatMemory(int $memory) : string {
    if ($memory >= 1024 * 1024 * 1024) {
        return \sprintf('%.1f GiB', $memory / 1024 / 1024 / 1024);
    }
    if ($memory >= 1024 * 1024) {
        return \sprintf('%.1f MiB', $memory / 1024 / 1024);
    }
    if ($memory >= 1024) {
        return \sprintf('%d KiB', $memory / 1024);
    }
    return \sprintf('%d B', $memory);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal