hiqdev /
billing-hiapi
| 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\customer; |
||
| 12 | |||
| 13 | use hiqdev\php\billing\customer\Customer; |
||
| 14 | use hiqdev\yii\DataMapper\hydrator\GeneratedHydrator; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Class CustomerHydrator. |
||
| 18 | * |
||
| 19 | * @author Andrii Vasyliev <[email protected]> |
||
| 20 | */ |
||
| 21 | class CustomerHydrator extends GeneratedHydrator |
||
| 22 | { |
||
| 23 | /** |
||
| 24 | * {@inheritdoc} |
||
| 25 | * @param object|Customer $object |
||
| 26 | */ |
||
| 27 | 2 | public function hydrate(array $data, $object) |
|
| 28 | { |
||
| 29 | 2 | if (!empty($data['seller'])) { |
|
| 30 | 2 | $data['seller'] = $this->hydrator->hydrate($data['seller'], Customer::class); |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 31 | } |
||
| 32 | |||
| 33 | 2 | return parent::hydrate($data, $object); |
|
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * {@inheritdoc} |
||
| 38 | * @param object|Customer $object |
||
| 39 | */ |
||
| 40 | public function extract($object) |
||
| 41 | { |
||
| 42 | return [ |
||
| 43 | 'id' => $object->getId(), |
||
| 44 | 'login' => $object->getLogin(), |
||
| 45 | 'seller' => $object->getSeller() ? $this->hydrator->extract($object->getSeller()) : null, |
||
| 46 | ]; |
||
| 47 | } |
||
| 48 | } |
||
| 49 |