Passed
Push — master ( 3fa2aa...35993a )
by Jesse
02:11
created

Choose::hydrator()   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\Mapper\Instruction\Relation;
6
7
use Stratadox\Hydration\Hydrates;
8
use Stratadox\Hydration\Mapper\InstructsHowToMap;
9
use Stratadox\Hydration\Mapper\MakesMap;
10
use Stratadox\Hydration\Mapper\Mapper;
11
use Stratadox\Hydration\Mapper\RepresentsChoice;
12
13
/**
14
 * Indicates a choice for one of several concrete types.
15
 *
16
 * @package Stratadox\Hydrate
17
 * @author Stratadox
18
 */
19
final class Choose implements RepresentsChoice
20
{
21
    private $class;
22
23
    private function __construct(MakesMap $class)
24
    {
25
        $this->class = $class;
26
    }
27
28
    public static function the(string $class) : RepresentsChoice
29
    {
30
        return new Choose(Mapper::forThe($class));
31
    }
32
33
    public function with(string $property, InstructsHowToMap $howToMap = null) : RepresentsChoice
34
    {
35
        $this->class = $this->class->property($property, $howToMap);
36
        return $this;
37
    }
38
39
    public function hydrator() : Hydrates
40
    {
41
        return $this->class->hydrator();
42
    }
43
}
44