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

ObserveBefore::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Stratadox\Hydrator;
5
6
final class ObserveBefore 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 ObserveBefore($hydrator, $observer);
24
    }
25
26
    public function writeTo(object $target, array $input): void
27
    {
28
        $this->observer->hydrating($target, $input);
29
        $this->hydrator->writeTo($target, $input);
30
    }
31
}
32