Failed Conditions
Push — master ( bea035...793b2f )
by Adrien
17:10 queued 55s
created

Utility::getUploadMaxFilesize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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
The function ini_parse_quantity was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
        return /** @scrutinizer ignore-call */ ini_parse_quantity(ini_get($key) ?: '0');
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