Invocation::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
/**
3
 * @link https://github.com/vuongxuongminh/laravel-async
4
 *
5
 * @copyright (c) Vuong Xuong Minh
6
 * @license [MIT](https://opensource.org/licenses/MIT)
7
 */
8
9
namespace VXM\Async;
10
11
use RuntimeException;
12
13
/**
14
 * @author Vuong Minh <[email protected]>
15
 * @since 1.0.0
16
 */
17
trait Invocation
18
{
19
    /**
20
     * Handle method name.
21
     *
22
     * @var string
23
     */
24
    protected $handleMethod = 'handle';
25
26
    /**
27
     * Call this class.
28
     */
29
    public function __invoke()
30
    {
31
        if (! method_exists($this, $this->handleMethod)) {
32
            throw new RuntimeException(sprintf('`handle` method must be define in (%s)', __CLASS__));
33
        }
34
35
        return app()->call([$this, $this->handleMethod]);
36
    }
37
}
38