ListStaffResponseDataTransformer::transform()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 14

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
dl 14
loc 14
rs 9.7998
c 0
b 0
f 0
cc 3
nc 3
nop 1
1
<?php
2
namespace OmnideskBundle\DataTransformer\Response\Staff;
3
4
use OmnideskBundle\DataTransformer\DataTransformerInterface;
5
use OmnideskBundle\DataTransformer\Model\StaffDataTransformer;
6
use OmnideskBundle\Response\Staff\ListStaffResponse;
7
8
/**
9
 * Class ListStaffResponseDataTransformer
10
 * @package OmnideskBundle\DataTransformer\Response
11
 */
12 View Code Duplication
class ListStaffResponseDataTransformer implements DataTransformerInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
{
14
    /**
15
     * @var StaffDataTransformer
16
     */
17
    protected $staffDataTransformer;
18
19
    /**
20
     * GetCasesResponseDataTransformer constructor.
21
     * @param StaffDataTransformer $staffDataTransformer
22
     */
23
    public function __construct(StaffDataTransformer $staffDataTransformer)
24
    {
25
        $this->staffDataTransformer = $staffDataTransformer;
26
    }
27
28
    /**
29
     * @param array $value
30
     * @return ListStaffResponse
31
     */
32
    public function transform($value)
33
    {
34
        $response = new ListStaffResponse();
35
36
        foreach ($value as $item) {
37
            if (isset($item['staff'])) {
38
                $response->addStaff($this->staffDataTransformer->transform($item['staff']));
39
            }
40
        }
41
42
        $response->setTotalCount($value['total_count'] ?? 0);
43
44
        return $response;
45
    }
46
47
    /**
48
     * @param ListStaffResponse $value
49
     * @return array
50
     */
51
    public function reverseTransform($value)
52
    {
53
        throw new \LogicException('Method not implemented.');
54
    }
55
}
56