Completed
Push — master ( 1df19b...3d6a4b )
by Trevor N.
11s
created

AbstractDelegateContextualBuilderHydrator::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
/**
3
 * Incoming
4
 *
5
 * @author    Trevor Suarez (Rican7)
6
 * @copyright (c) Trevor Suarez
7
 * @link      https://github.com/Rican7/incoming
8
 * @license   MIT
9
 */
10
11
declare(strict_types=1);
12
13
namespace Incoming\Hydrator;
14
15
use Incoming\Structure\Map;
16
17
/**
18
 * An abstract, context enabled extension of the `AbstractDelegateBuilderHydrator`.
19
 *
20
 * @see AbstractDelegateBuilderHydrator
21
 * @see AbstractDelegateContextualBuilder
22
 * @see AbstractDelegateContextualHydrator
23
 */
24
abstract class AbstractDelegateContextualBuilderHydrator extends AbstractDelegateBuilderHydrator implements
25
    ContextualBuilder,
26
    ContextualHydrator
27
{
28
29
    /**
30
     * {@inheritdoc}
31
     *
32
     * @param mixed $incoming The input data.
33
     * @param Map|null $context An optional generic key-value map, for providing
34
     *  contextual values during the build process.
35
     * @return mixed The built model.
36
     */
37 3
    public function build($incoming, Map $context = null)
38
    {
39 3
        $callable = $this->getDelegateBuilder();
40
41 3
        return $callable($incoming, $context);
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     *
47
     * @param mixed $incoming The input data.
48
     * @param mixed $model The model to hydrate.
49
     * @param Map|null $context An optional generic key-value map, for providing
50
     *  contextual values during the hydrate process.
51
     * @return mixed The hydrated model.
52
     */
53 3
    public function hydrate($incoming, $model, Map $context = null)
54
    {
55 3
        $callable = $this->getDelegateHydrator();
56
57 3
        return $callable($incoming, $model, $context);
58
    }
59
}
60