Completed
Push — master ( 979590...f7b9af )
by John
06:14
created

ObjectHydrator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A hydrate() 0 4 1
A dehydrate() 0 4 1
1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of the KleijnWeb\SwaggerBundle package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace KleijnWeb\SwaggerBundle\Hydrator;
10
11
use KleijnWeb\PhpApi\Descriptions\Description\Schema\Schema;
12
use KleijnWeb\PhpApi\Hydrator\ProcessorBuilder;
13
14
/**
15
 * Wrapper around ProcessorBuilder for compatibility
16
 *
17
 * @author John Kleijn <[email protected]>
18
 */
19
class ObjectHydrator
20
{
21
    /**
22
     * @var ProcessorBuilder
23
     */
24
    private $builder;
25
26
    /**
27
     * ObjectHydrator constructor.
28
     * @param ProcessorBuilder $builder
29
     */
30
    public function __construct(ProcessorBuilder $builder)
31
    {
32
        $this->builder = $builder;
33
    }
34
35
    /**
36
     * @param mixed  $value
37
     * @param Schema $schema
38
     * @return mixed
39
     */
40
    public function hydrate($value, Schema $schema)
41
    {
42
        return $this->builder->build($schema)->hydrate($value);
43
    }
44
45
    /**
46
     * @param mixed  $value
47
     * @param Schema $schema
48
     * @return mixed
49
     */
50
    public function dehydrate($value, Schema $schema)
51
    {
52
        return $this->builder->build($schema)->dehydrate($value);
53
    }
54
}
55