ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
PHPMemoryLimit.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27trait PHPMemoryLimit
28{
29 public function getSizeLimitInBytes(): int
30 {
31 $memory_limit = ini_get('memory_limit');
32 if (preg_match('/^(\d+)(.)$/', $memory_limit, $matches)) {
33 $memory_limit = match ($matches[2]) {
34 'K' => $matches[1] * 1024,
35 'M' => $matches[1] * 1024 * 1024,
36 'G' => $matches[1] * 1024 * 1024 * 1024,
37 default => $memory_limit,
38 };
39 }
40 return (int) $memory_limit;
41 }
42}