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 — master ( c517ee...c7ab7d )
by Jad
17:39
created

src/Console/Environment/MemoryLimit.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/**
4
 * This file is part of the ApiGen (http://apigen.org)
5
 *
6
 * For the full copyright and license information, please view
7
 * the file LICENSE that was distributed with this source code.
8
 */
9
10
namespace ApiGen\Console\Environment;
11
12 View Code Duplication
class MemoryLimit
13
{
14
15
    /**
16
     * @param string $newMemoryLimit
17
     */
18
    public function setMemoryLimitTo($newMemoryLimit)
19
    {
20
        if (function_exists('ini_set')) {
21
            $memoryLimit = trim(ini_get('memory_limit'));
22
            if ($memoryLimit !== -1 && $this->getMemoryInBytes($memoryLimit) < 512 * 1024 * 1024) {
0 ignored issues
show
Unused Code Bug introduced by
The strict comparison !== seems to always evaluate to true as the types of $memoryLimit (string) and -1 (integer) can never be identical. Maybe you want to use a loose comparison != instead?
Loading history...
23
                @ini_set('memory_limit', $newMemoryLimit);
24
            }
25
            unset($memoryInBytes, $memoryLimit);
26
        }
27
    }
28
29
30
    /**
31
     * @param string $value
32
     * @return int
33
     */
34
    private function getMemoryInBytes($value)
35
    {
36
        $unit = strtolower(substr($value, -1, 1));
37
        $value = (int) $value;
38
        if ($unit === 'g') {
39
            return $value * 1024 * 1024 * 1024;
40
        }
41
        if ($unit === 'm') {
42
            return $value * 1024 * 1024;
43
        }
44
        if ($unit === 'k') {
45
            return $value * 1024;
46
        }
47
    }
48
}
49