Enable::execute()   A
last analyzed

Complexity

Conditions 5
Paths 8

Size

Total Lines 25
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 15
nc 8
nop 2
dl 0
loc 25
rs 9.4555
c 0
b 0
f 0
1
<?php namespace Comodojo\Extender\Socket\Commands\Scheduler;
2
3
use \Comodojo\Daemon\Daemon;
4
use \Comodojo\Extender\Schedule\Manager;
5
use \Comodojo\RpcServer\Request\Parameters;
6
use \Comodojo\Exception\RpcException;
7
use \InvalidArgumentException;
8
use \Exception;
9
10
class Enable {
11
12
    public static function execute(Parameters $params, Daemon $daemon) {
13
14
        $manager = new Manager(
15
            $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

15
            $daemon->/** @scrutinizer ignore-call */ 
16
                     getConfiguration(),
Loading history...
16
            $daemon->getLogger(),
17
            $daemon->getEvents()
18
        );
19
20
        $id = $params->get('id');
21
        $name = $params->get('name');
22
23
        try {
24
25
            $enable = empty($id) ? $manager->enableByName($name) :
26
                $manager->enable($id);
27
28
        } catch (InvalidArgumentException $iae) {
29
            throw new RpcException("No record could be found", -31002);
30
        } catch (Exception $e) {
31
            throw $e;
32
        }
33
34
        $refresh = Refresh::execute($params, $daemon);
35
36
        return $enable && $refresh;
37
38
    }
39
40
}
41