Completed
Push — master ( f5a8d9...ecb36f )
by Clayton
10s
created

ServiceCaller::queue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
dl 10
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
namespace PerfectOblivion\Services;
4
5
use Illuminate\Container\Container;
6
use Illuminate\Contracts\Bus\Dispatcher;
7
use PerfectOblivion\Services\Exceptions\ServiceHandlerMethodException;
8
9
class ServiceCaller extends AbstractServiceCaller
10
{
11
    /**
12
     * Call a service through its appropriate handler.
13
     *
14
     * @param  string  $service
15
     * @param  mixed  ...$params
16
     *
17
     * @return mixed
18
     */
19
    public function call($service, ...$params)
20
    {
21
        if (! $this->hasHandler($service)) {
22
            throw ServiceHandlerMethodException::notFound($service);
23
        }
24
25
        return $this->container->make($service)->{$this::$handlerMethod}(...$params);
26
    }
27
28
    /**
29
     * Push the service call to the queue..
30
     *
31
     * @param  string  $service
32
     * @param  mixed  ...$params
33
     *
34
     * @throws \PerfectOblivion\Services\Exceptions\ServiceHandlerMethodException
35
     *
36
     * @return mixed
37
     */
38 View Code Duplication
    public function queue($service, ...$params)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
39
    {
40
        if (! $this->hasHandler($service)) {
41
            throw ServiceHandlerMethodException::notFound($service);
42
        }
43
44
        return resolve(Dispatcher::class)->dispatch(
45
            new QueuedService(Container::getInstance()->make($service), $params)
46
        );
47
    }
48
}
49