GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — analysis-qoa5jK ( 418d75 )
by butschster
08:33
created

MaxFileSizeTrait   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 25
c 2
b 1
f 0
dl 0
loc 48
rs 10
wmc 8

2 Methods

Rating   Name   Duplication   Size   Complexity  
A convertMB() 0 21 5
A getMaxFileSize() 0 11 3
1
<?php
2
3
namespace SleepingOwl\Admin\Traits;
4
5
trait MaxFileSizeTrait
6
{
7
    /**
8
     * @var number
9
     */
10
    protected $maxFileSize;
11
12
    /**
13
     * @return number
14
     */
15
    public function getMaxFileSize()
16
    {
17
        if (! $this->maxFileSize) {
18
            try {
19
                $this->maxFileSize = $this->convertMB(ini_get('upload_max_filesize'));
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->convertMB(ini_get('upload_max_filesize')) of type string is incompatible with the declared type double|integer of property $maxFileSize.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
20
            } catch (\Exception $e) {
21
                $this->maxFileSize = 5;
22
            }
23
        }
24
25
        return $this->maxFileSize;
26
    }
27
28
    /**
29
     * Конвертирование значения
30
     * максимального размера загружаемого файла.
31
     */
32
    public function convertMB($value)
33
    {
34
        if (is_numeric($value)) {
35
            return $value;
36
        } else {
37
            $value_length = strlen($value);
38
            $qty = substr($value, 0, $value_length - 1);
39
            $unit = strtolower(substr($value, $value_length - 1));
40
            switch ($unit) {
41
                case 'k':
42
                $qty /= 1024;
43
                break;
44
                case 'm':
45
                $qty = $qty;
46
                break;
47
                case 'g':
48
                $qty *= 1024;
49
                break;
50
            }
51
52
            return $qty;
53
        }
54
    }
55
}
56