RuntimeUtils::executeWithPostAction()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 3
b 0
f 0
nc 2
nop 2
dl 0
loc 13
rs 10
1
<?php
2
/**
3
 * Copyright © Vaimo Group. All rights reserved.
4
 * See LICENSE_VAIMO.txt for license details.
5
 */
6
namespace Vaimo\ComposerPatches\Utils;
7
8
class RuntimeUtils
9
{
10
    public function setEnvironmentValues($values)
11
    {
12
        foreach ($values as $name => $value) {
13
            putenv($name . '=' . $value);
14
        }
15
    }
16
17
    public function executeWithPostAction($action, $postAction)
18
    {
19
        try {
20
            $result = $action();
21
        } catch (\Exception $exception) {
22
            $postAction();
23
24
            throw $exception;
25
        }
26
27
        $postAction();
28
29
        return $result;
30
    }
31
}
32