Passed
Push — master ( 9b8d7a...13dd3e )
by Stefano
03:16
created

SystemHelper::getMaxFileSize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
4
namespace App\View\Helper;
5
6
use Cake\View\Helper;
7
8
/**
9
 * System helper
10
 */
11
class SystemHelper extends Helper
12
{
13
    /**
14
     * Get the minimum value between post_max_size and upload_max_filesize.
15
     *
16
     * @return int
17
     */
18
    public function getMaxFileSize(): int
19
    {
20
        $postMaxSize = intVal(substr(ini_get('post_max_size'), 0, -1));
21
        $uploadMaxFilesize = intVal(substr(ini_get('upload_max_filesize'), 0, -1));
22
23
        return min($postMaxSize, $uploadMaxFilesize) * 1024 * 1024;
24
    }
25
}
26