Passed
Push — master ( 373e60...256112 )
by Dmitry
25:12 queued 10:02
created

SumsHydrator   A

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;
0 ignored issues
show
Bug introduced by
The type hiqdev\DataMapper\Hydrator\GeneratedHydrator was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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