Completed
Push — master ( e481c7...bcdb1b )
by Marco
35:35 queued 20:00
created

Get   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
B execute() 0 26 2
1
<?php namespace Comodojo\Extender\Socket\Commands\Scheduler;
2
3
use \Comodojo\Daemon\Daemon;
4
use \Comodojo\Extender\Schedule\Manager;
5
use \Comodojo\Extender\Socket\Messages\Task\Request as TaskRequestMessage;
6
use \Comodojo\Extender\Socket\Messages\Scheduler\Schedule as ScheduleMessage;
7
use \Comodojo\RpcServer\Request\Parameters;
8
9
class Get {
10
11
    public static function execute(Parameters $params, Daemon $daemon) {
12
13
        $manager = new Manager(
14
            $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

14
            $daemon->/** @scrutinizer ignore-call */ 
15
                     getConfiguration(),
Loading history...
15
            $daemon->getLogger(),
16
            $daemon->getEvents()
17
        );
18
19
        $id = $params->get('id');
20
        $name = $params->get('name');
21
22
        $schedule = empty($id) ? $manager->getByName($name) :
23
            $manager->get($id);
24
25
        $request = $schedule->getRequest();
0 ignored issues
show
Bug introduced by
The method getRequest() does not exist on null. ( Ignorable by Annotation )

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

25
        /** @scrutinizer ignore-call */ 
26
        $request = $schedule->getRequest();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
26
27
        $schedule_message = new ScheduleMessage();
28
        $schedule_message->setId($schedule->getId());
29
        $schedule_message->setName($schedule->getName());
30
        $schedule_message->setDescription($schedule->getDescription());
31
        $schedule_message->setExpression((string)$schedule->getExpression());
32
        $schedule_message->setEnabled($schedule->getEnabled());
33
34
        $request_message = $request->convertToMessage();
35
36
        return [$schedule_message->export(), $request_message->export()];
37
38
    }
39
40
}
41