Caller::call()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 13
rs 10
cc 3
nc 3
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Umbrellio\Jaravel\Services;
6
7
use Illuminate\Support\Facades\App;
8
use Umbrellio\Jaravel\Services\Exceptions\CallerException;
9
10
class Caller
11
{
12
    public static function call($callable, array $params)
13
    {
14
        if (is_callable($callable)) {
15
            return $callable(...$params);
16
        }
17
18
        if (is_string($callable)) {
19
            $callableObject = App::make($callable);
20
21
            return $callableObject(...$params);
22
        }
23
24
        throw new CallerException('Unexpected callable parameter');
25
    }
26
}
27