ByJid   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 28 2
1
<?php namespace Comodojo\Extender\Socket\Commands\Worklog;
2
3
use \Comodojo\Daemon\Daemon;
4
use \Comodojo\RpcServer\Request\Parameters;
5
use \Comodojo\Extender\Worklog\Manager;
6
use \Comodojo\Extender\Socket\Messages\Worklog\Filter;
7
use \Comodojo\Extender\Transformers\WorklogTransformer;
8
use \League\Fractal\Manager as FractalManager;
9
use \League\Fractal\Resource\Collection;
10
11
class ByJid {
12
13
    public static function execute(Parameters $params, Daemon $daemon) {
14
15
        $jid = $params->get('jid');
16
        $filter = $params->get('filter');
17
18
        $manager = new Manager(
19
            $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

19
            $daemon->/** @scrutinizer ignore-call */ 
20
                     getConfiguration(),
Loading history...
20
            $daemon->getLogger(),
21
            $daemon->getEvents()
22
        );
23
24
        if ( empty($filter) ) {
25
            $data = $manager->get(['jid' => $jid]);
26
        } else {
27
            $f = Filter::createFromExport($filter);
28
            $data = $manager->get(
29
                ['jid' => $jid],
30
                $f->getLimit(),
31
                $f->getOffset(),
32
                $f->getReverse()
33
            );
34
        }
35
36
        $resource = new Collection($data, new WorklogTransformer);
37
        $fractal = new FractalManager();
38
        $data = $fractal->createData($resource)->toArray();
39
40
        return $data['data'];
41
42
    }
43
44
}
45