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

Utility   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 23
ccs 8
cts 8
cp 1
rs 10
c 1
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A fromIni() 0 3 2
A toMebibyte() 0 3 1
A getPostMaxSize() 0 3 1
A getUploadMaxFilesize() 0 3 1
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