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\bill; |
||
12 | |||
13 | use hiqdev\php\billing\bill\BillState; |
||
14 | use hiqdev\yii\DataMapper\hydrator\GeneratedHydrator; |
||
15 | |||
16 | /** |
||
17 | * BillState Hydrator. |
||
18 | * |
||
19 | * @author Andrii Vasyliev <[email protected]> |
||
20 | */ |
||
21 | class BillStateHydrator extends GeneratedHydrator |
||
22 | { |
||
23 | public function hydrate(array $data, $object) |
||
24 | { |
||
25 | return BillState::fromString($data['state'] ?? reset($data)); |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * {@inheritdoc} |
||
30 | * @param BillState $object |
||
31 | */ |
||
32 | public function extract($object) |
||
33 | { |
||
34 | return $object->getName(); |
||
0 ignored issues
–
show
|
|||
35 | } |
||
36 | } |
||
37 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: