asSize() public method

If [[sizeFormatBase]] is 1024, binary prefixes (e.g. kibibyte/KiB, mebibyte/MiB, ...) are used in the formatting result.
See also: sizeFormatBase
See also: asShortSize
public asSize ( string | integer | float $value, integer $decimals = null, array $options = [], array $textOptions = [] ) : string
$value string | integer | float value in bytes to be formatted.
$decimals integer the number of digits after the decimal point.
$options array optional configuration for the number formatter. This parameter will be merged with [[numberFormatterOptions]].
$textOptions array optional configuration for the number formatter. This parameter will be merged with [[numberFormatterTextOptions]].
return string the formatted result.
Example #1
0
 /**
  * https://github.com/yiisoft/yii2/issues/4960
  */
 public function testAsSizeConfiguration()
 {
     $this->assertSame("1023 bytes", $this->formatter->asSize(1023));
     $this->assertSame("1023 B", $this->formatter->asShortSize(1023));
     $this->formatter->thousandSeparator = '.';
     $this->assertSame("1023 bytes", $this->formatter->asSize(1023));
     $this->assertSame("1023 B", $this->formatter->asShortSize(1023));
 }