helpers.php ➔ repeat_and_rescue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
/**
3
 * This file is part of Evacuator package.
4
 *
5
 * @author Serafim <[email protected]>
6
 * @date 06.04.2016 15:45
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
use Serafim\Evacuator\Evacuator;
12
13
if (!function_exists('rescue')) {
14
    /**
15
     * @param Closure $what
16
     * @return mixed
17
     */
18
    function rescue(\Closure $what)
19
    {
20
        return (new Evacuator($what))
21
            ->retries(Evacuator::INFINITY_RETRIES)
22
            ->invoke();
23
    }
24
}
25
26
if (!function_exists('repeat')) {
27
    /**
28
     * @param int $repeatsCount
29
     * @param Closure $what
30
     * @return mixed
31
     */
32
    function repeat_and_rescue(int $repeatsCount, \Closure $what)
33
    {
34
        return (new Evacuator($what))
35
            ->retries(abs($repeatsCount))
36
            ->invoke();
37
    }
38
}
39