Completed
Push — master ( 8b1836...4d4488 )
by Andrii
12:59
created

ActionStateHydrator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A hydrate() 0 4 1
A extract() 0 4 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-2018, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\billing\hiapi\action;
12
13
use hiqdev\php\billing\action\ActionState;
14
use hiqdev\yii\DataMapper\hydrator\GeneratedHydrator;
15
16
/**
17
 * ActionState Hydrator.
18
 *
19
 * @author Andrii Vasyliev <[email protected]>
20
 */
21
class ActionStateHydrator extends GeneratedHydrator
22
{
23
    public function hydrate(array $data, $object)
24
    {
25
        return ActionState::fromString($data['state'] ?? reset($data));
26
    }
27
28
    /**
29
     * @param ActionState $object
30
     */
31
    public function extract($object)
32
    {
33
        return $object->getName();
34
    }
35
}
36