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
Pull Request — master (#290)
by
unknown
01:34
created

ExecutionTime::getMaxExecution()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Queue;
4
5
trait ExecutionTime
6
{
7
8
    /**
9
     * Set PHP max execution time
10
     * Skips setting in tests to avoid timeout issues
11
     *
12
     * @param int $seconds
13
     */
14
    protected function setMaxExecution(int $seconds): void
15
    {
16
        ini_set('max_execution_time', $seconds);
17
    }
18
19
    /**
20
     * Get max execution time
21
     *
22
     * @return int
23
     */
24
    protected function getMaxExecution(): int
25
    {
26
        return ini_get('max_execution_time');
27
    }
28
29
    /**
30
     * @param int $executionTime
31
     * @param callable $callback
32
     * @return mixed
33
     */
34
    protected function withExecutionTime(int $executionTime, callable $callback)
35
    {
36
        $originalTime = $this->getMaxExecution();
37
38
        try {
39
            $this->setMaxExecution($executionTime);
40
41
            return $callback();
42
        } finally {
43
            $this->setMaxExecution($originalTime);
44
        }
45
    }
46
}
47