Ecodev /
graphql-upload
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace GraphQL\Upload; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * @internal |
||
| 9 | */ |
||
| 10 | final class Utility |
||
| 11 | { |
||
| 12 | 12 | public static function getPostMaxSize(): int |
|
| 13 | { |
||
| 14 | 12 | return self::fromIni('post_max_size'); |
|
| 15 | } |
||
| 16 | |||
| 17 | 1 | public static function getUploadMaxFilesize(): int |
|
| 18 | { |
||
| 19 | 1 | return self::fromIni('upload_max_filesize'); |
|
| 20 | } |
||
| 21 | |||
| 22 | 13 | private static function fromIni(string $key): int |
|
| 23 | { |
||
| 24 | 13 | return ini_parse_quantity(ini_get($key) ?: '0'); |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @param int|numeric-string $value |
||
| 29 | */ |
||
| 30 | 2 | public static function toMebibyte(string|int $value): string |
|
| 31 | { |
||
| 32 | 2 | return number_format($value / 1024 / 1024, 2, thousands_separator: "'") . ' MiB'; |
|
| 33 | } |
||
| 34 | } |
||
| 35 |