Code Duplication    Length = 25-27 lines in 2 locations

src/Plugin/Temporal.php 2 locations

@@ 26-50 (lines=25) @@
23
        $this->aggregator = new Aggregator($this);
24
    }
25
26
    public function getReference($entity, $id, $target, $date)
27
    {
28
        $entity = $this->entityNameToId($entity);
29
        $target = $this->entityNameToId($target);
30
        $date = $this->getTimestamp($date);
31
32
        $rows = $this->mapper->getClient()->getSpace('_temporal_reference_state')
33
            ->select([$entity, $id, $target, $date], 0, 1, 0, 4) // [key, index, limit, offset, iterator = LE]
34
            ->getData();
35
36
        if (count($rows)) {
37
            $row = $rows[0];
38
            if ([$entity, $id, $target] == [$row[0], $row[1], $row[2]]) {
39
                $state = $this->mapper->findOne('_temporal_reference_state', [
40
                    'entity' => $entity,
41
                    'id' => $id,
42
                    'target' => $target,
43
                    'begin' => $row[3]
44
                ]);
45
                if (!$state->end || $state->end >= $date) {
46
                    return $state->targetId;
47
                }
48
            }
49
        }
50
    }
51
52
    public function getReferences($target, $targetId, $source, $date)
53
    {
@@ 52-78 (lines=27) @@
49
        }
50
    }
51
52
    public function getReferences($target, $targetId, $source, $date)
53
    {
54
        $target = $this->entityNameToId($target);
55
        $source = $this->entityNameToId($source);
56
        $date = $this->getTimestamp($date);
57
58
        $rows = $this->mapper->getClient()->getSpace('_temporal_reference_aggregate')
59
            ->select([$target, $targetId, $source, $date], 0, 1, 0, 4) // [key, index, limit, offset, iterator = LE]
60
            ->getData();
61
62
        if (count($rows)) {
63
            $row = $rows[0];
64
            if ([$target, $targetId, $source] == [$row[0], $row[1], $row[2]]) {
65
                $state = $this->mapper->findOne('_temporal_reference_aggregate', [
66
                    'entity' => $target,
67
                    'id'     => $targetId,
68
                    'source' => $source,
69
                    'begin'  => $row[3]
70
                ]);
71
72
                if (!$state->end || $state->end > $date) {
73
                    return $state->data;
74
                }
75
            }
76
        }
77
        return [];
78
    }
79
80
    public function reference(array $reference)
81
    {