Completed
Push — master ( 85c19c...2798ac )
by Jesse
02:11
created

To::ignoreThe()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Stratadox\TableLoader;
5
6
/**
7
 * Locates the target object for the relationship.
8
 *
9
 * @author Stratadox
10
 */
11
final class To implements KnowsWhereToLookTo
12
{
13
    private $who;
14
    private $identity;
15
16
    private function __construct(string $who, IdentifiesEntities $identity)
17
    {
18
        $this->who = $who;
19
        $this->identity = $identity;
20
    }
21
22
    /**
23
     * Makes a new target locator.
24
     *
25
     * @param string             $label    The label of the source objects.
26
     * @param IdentifiesEntities $identity The mechanism to identify the target
27
     *                                     entity of the row.
28
     * @return KnowsWhereToLook
29
     */
30
    public static function the(
31
        string $label,
32
        IdentifiesEntities $identity
33
    ): KnowsWhereToLook {
34
        return new self($label, $identity);
35
    }
36
37
    /** @inheritdoc */
38
    public function label(): string
39
    {
40
        return $this->who;
41
    }
42
43
    /** @inheritdoc */
44
    public function this(array $relationship): string
45
    {
46
        return $this->identity->forLoading($relationship);
47
    }
48
49
    /** @inheritdoc */
50
    public function ignoreThe(array $row): bool
51
    {
52
        return $this->identity->isNullFor($row);
53
    }
54
}
55