Add::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 11
nc 2
nop 2
dl 0
loc 19
rs 9.9
c 0
b 0
f 0
1
<?php namespace Comodojo\Extender\Socket\Commands\Queue;
2
3
use \Comodojo\Extender\Queue\Manager;
4
use \Comodojo\Daemon\Daemon;
5
use \Comodojo\RpcServer\Request\Parameters;
6
use \Comodojo\Extender\Socket\Messages\Task\Request as TaskRequestMessage;
7
use \Comodojo\Extender\Task\Request as TaskRequest;
8
use \Comodojo\Exception\RpcException;
9
use \Exception;
10
11
class Add {
12
13
    public static function execute(Parameters $params, Daemon $daemon) {
14
15
        $message = $params->get('request');
16
17
        try {
18
            $request = TaskRequest::createFromMessage(
19
                TaskRequestMessage::createFromExport($message)
20
            );
21
        } catch (Exception $e) {
22
            throw new RpcException("Invalid message payload in request", -32600);
23
        }
24
25
        $manager = new Manager(
26
            $daemon->getConfiguration(),
0 ignored issues
show
Bug introduced by
The method getConfiguration() does not exist on Comodojo\Daemon\Daemon. It seems like you code against a sub-type of Comodojo\Daemon\Daemon such as Comodojo\Extender\ExtenderDaemon. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
            $daemon->/** @scrutinizer ignore-call */ 
27
                     getConfiguration(),
Loading history...
27
            $daemon->getLogger(),
28
            $daemon->getEvents()
29
        );
30
31
        return $manager->add($request);
32
33
    }
34
35
}
36