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

ObjectHydrator::hydrate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
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