Code Duplication    Length = 27-29 lines in 2 locations

src/Plugin/Temporal.php 2 locations

@@ 26-52 (lines=27) @@
23
        $this->aggregator = new Aggregator($this);
24
    }
25
26
    public function getReference($entity, $id, $target, $date)
27
    {
28
        $this->schema->init('reference');
29
30
        $entity = $this->entityNameToId($entity);
31
        $target = $this->entityNameToId($target);
32
        $date = $this->getTimestamp($date);
33
34
        $rows = $this->mapper->getClient()->getSpace('_temporal_reference_state')
35
            ->select([$entity, $id, $target, $date], 0, 1, 0, 4) // [key, index, limit, offset, iterator = LE]
36
            ->getData();
37
38
        if (count($rows)) {
39
            $row = $rows[0];
40
            if ([$entity, $id, $target] == [$row[0], $row[1], $row[2]]) {
41
                $state = $this->mapper->findOne('_temporal_reference_state', [
42
                    'entity' => $entity,
43
                    'id' => $id,
44
                    'target' => $target,
45
                    'begin' => $row[3]
46
                ]);
47
                if (!$state->end || $state->end >= $date) {
48
                    return $state->targetId;
49
                }
50
            }
51
        }
52
    }
53
54
    public function getReferenceLog($entity, $id, $target)
55
    {
@@ 68-96 (lines=29) @@
65
        return $log;
66
    }
67
68
    public function getReferences($target, $targetId, $source, $date)
69
    {
70
        $this->schema->init('reference');
71
72
        $target = $this->entityNameToId($target);
73
        $source = $this->entityNameToId($source);
74
        $date = $this->getTimestamp($date);
75
76
        $rows = $this->mapper->getClient()->getSpace('_temporal_reference_aggregate')
77
            ->select([$target, $targetId, $source, $date], 0, 1, 0, 4) // [key, index, limit, offset, iterator = LE]
78
            ->getData();
79
80
        if (count($rows)) {
81
            $row = $rows[0];
82
            if ([$target, $targetId, $source] == [$row[0], $row[1], $row[2]]) {
83
                $state = $this->mapper->findOne('_temporal_reference_aggregate', [
84
                    'entity' => $target,
85
                    'id'     => $targetId,
86
                    'source' => $source,
87
                    'begin'  => $row[3]
88
                ]);
89
90
                if (!$state->end || $state->end > $date) {
91
                    return $state->data;
92
                }
93
            }
94
        }
95
        return [];
96
    }
97
98
    public function reference(array $reference)
99
    {