Completed
Push — master ( 9c7fd0...afc45c )
by Andrii
10:58
created

TargetHydrator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A hydrate() 0 4 1
A extract() 0 10 1
1
<?php
2
/**
3
 * API for Billing
4
 *
5
 * @link      https://github.com/hiqdev/billing-hiapi
6
 * @package   billing-hiapi
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\billing\hiapi\target;
12
13
use hiqdev\yii\DataMapper\hydrator\GeneratedHydratorTrait;
14
use hiqdev\yii\DataMapper\hydrator\RootHydratorAwareTrait;
15
use Zend\Hydrator\HydratorInterface;
16
17
/**
18
 * Class TargetHydrator.
19
 *
20
 * @author Andrii Vasyliev <[email protected]>
21
 */
22
class TargetHydrator implements HydratorInterface
23
{
24
    use RootHydratorAwareTrait;
25
    use GeneratedHydratorTrait {
26
        hydrate as generatedHydrate;
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     * @param object|Target $object
32
     */
33
    public function hydrate(array $data, $object)
34
    {
35
        return $this->generatedHydrate($data, $object);
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     * @param object|Target $object
41
     */
42
    public function extract($object)
43
    {
44
        $result = array_filter([
45
            'id'            => $object->getId(),
46
            'type'          => $object->getType(),
47
            'name'          => $object->getName(),
48
        ]);
49
50
        return $result;
51
    }
52
}
53