WorklogTransformer::transform()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 22
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 17
nc 4
nop 1
dl 0
loc 22
rs 9.7
c 0
b 0
f 0
1
<?php namespace Comodojo\Extender\Transformers;
2
3
use \Comodojo\Extender\Orm\Entities\Worklog;
4
use \League\Fractal\TransformerAbstract;
5
6
class WorklogTransformer extends TransformerAbstract {
7
8
    public function transform (Worklog $worklog) {
9
10
        $parameters = $worklog->getParameters()->export();
11
        if ( isset($parameters['parent']) && $parameters['parent'] instanceof \Comodojo\Extender\Task\Result ) {
12
            $parameters['parent'] = $parameters['parent']->export();
13
        }
14
15
        $jid = $worklog->getJid();
16
17
        return [
18
            'id' => (int) $worklog->getId(),
19
            'name' => $worklog->getName(),
20
            'uid' => $worklog->getUid(),
21
            'pid' => $worklog->getPid(),
22
            'jid' => empty($jid) ? null : $jid->getId(),
0 ignored issues
show
Bug introduced by
The method getId() does not exist on integer. ( Ignorable by Annotation )

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

22
            'jid' => empty($jid) ? null : $jid->/** @scrutinizer ignore-call */ getId(),

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...
23
            'parent_uid' => $worklog->getParentUid(),
24
            'task' => $worklog->getTask(),
25
            'parameters' => $parameters,
26
            'status' => $worklog->getStatus(),
27
            'result' => $worklog->getResult(),
28
            'start_time' => $worklog->getStartTime(),
29
            'end_time' => $worklog->getEndTime()
30
        ];
31
32
    }
33
34
}
35