Passed
Push — master ( bdc1f1...0b2259 )
by Jesse
03:03
created

ObserveAfter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A hydrating() 0 5 1
A __construct() 0 6 1
A writeTo() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Stratadox\Hydrator;
5
6
final class ObserveAfter implements Hydrates
7
{
8
    private $hydrator;
9
    private $observer;
10
11
    private function __construct(
12
        Hydrates $hydrator,
13
        ObservesHydration $observer
14
    ) {
15
        $this->hydrator = $hydrator;
16
        $this->observer = $observer;
17
    }
18
19
    public static function hydrating(
20
        Hydrates $hydrator,
21
        ObservesHydration $observer
22
    ): Hydrates {
23
        return new ObserveAfter($hydrator, $observer);
24
    }
25
26
    public function writeTo(object $target, array $input): void
27
    {
28
        $this->hydrator->writeTo($target, $input);
29
        $this->observer->hydrating($target, $input);
30
    }
31
}
32