Completed
Push — master ( 0b2259...8886fc )
by Jesse
02:25
created

Observe   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A observe() 0 3 1
A hydrate() 0 3 1
A __construct() 0 6 1
A hydrating() 0 5 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Stratadox\Hydrator;
5
6
abstract class Observe 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 static($hydrator, $observer);
24
    }
25
26
    /** @throws CannotHydrate */
27
    final protected function hydrate(object $target, array $input): void
28
    {
29
        $this->hydrator->writeTo($target, $input);
30
    }
31
32
    final protected function observe(object $target, array $input): void
33
    {
34
        $this->observer->hydrating($target, $input);
35
    }
36
}
37