Completed
Push — master ( cd03ce...a0b884 )
by Jesse
02:19
created

Properties::current()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stratadox\Hydration\Mapping;
6
7
use Closure;
8
use Stratadox\Hydration\MapsProperties;
9
use Stratadox\Hydration\MapsProperty;
10
use Stratadox\ImmutableCollection\ImmutableCollection;
11
12
/**
13
 * Defines how to map a specific structure of data to an object.
14
 *
15
 * @package Stratadox\Hydrate
16
 * @author Stratadox
17
 */
18
final class Properties extends ImmutableCollection implements MapsProperties
19
{
20
    public function __construct(MapsProperty ...$properties)
21
    {
22
        parent::__construct(...$properties);
23
    }
24
25
    public static function map(
26
        MapsProperty ...$properties
27
    ) : self
28
    {
29
        return new self(...$properties);
30
    }
31
32
    public function current() : MapsProperty
33
    {
34
        return parent::current();
35
    }
36
37
    public function writeData($object, Closure $setter, array $data) : void
38
    {
39
        foreach ($this as $property) {
40
            $setter->call($object, $property->name(), $property->value($data));
41
        }
42
    }
43
}
44