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

AbstractDelegateContextualBuilderHydrator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 36
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 6 1
A hydrate() 0 6 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