ById   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 19 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\Transformers\WorklogTransformer;
7
use \League\Fractal\Manager as FractalManager;
8
use \League\Fractal\Resource\Item;
9
use \Comodojo\Exception\RpcException;
10
11
class ById {
12
13
    public static function execute(Parameters $params, Daemon $daemon) {
14
15
        $id = $params->get('id');
16
17
        $manager = new Manager(
18
            $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

18
            $daemon->/** @scrutinizer ignore-call */ 
19
                     getConfiguration(),
Loading history...
19
            $daemon->getLogger(),
20
            $daemon->getEvents()
21
        );
22
23
        $data = $manager->getOne(['id' => $id]);
24
25
        if ( empty($data) ) throw new RpcException("No record could be found", -31002);
26
27
        $resource = new Item($data, new WorklogTransformer);
28
        $fractal = new FractalManager();
29
        $data = $fractal->createData($resource)->toArray();
30
31
        return $data['data'];
32
33
    }
34
35
}
36