SumsHydrator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 6
c 0
b 0
f 0
dl 0
loc 18
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A extract() 0 4 1
A hydrate() 0 6 2
1
<?php declare(strict_types=1);
2
3
namespace hiqdev\php\billing\price;
4
5
use hiqdev\DataMapper\Hydrator\GeneratedHydrator;
6
7
class SumsHydrator extends GeneratedHydrator
8
{
9
    public function hydrate(array $data, $object): object
10
    {
11
        if (!isset($data['sums'])) {
12
            throw new PriceInvalidArgumentException('Missing required key: sums');
13
        }
14
        return new Sums($data['sums']);
15
    }
16
17
    /**
18
     * {@inheritdoc}
19
     * @param Sums $object
20
     */
21
    public function extract($object): array
22
    {
23
        return [
24
            'values'  => $object->values(),
25
        ];
26
    }
27
}
28