Enable   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 25 5
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