Code Duplication    Length = 26-28 lines in 3 locations

src/Palladium/Mapper/Identity.php 1 location

@@ 88-113 (lines=26) @@
85
    }
86
87
88
    private function fetchByToken(Entity\Identity $entity)
89
    {
90
        $sql = "SELECT identity_id      AS id,
91
                       parent_id        AS parentId,
92
                       account_id       AS accountId,
93
                       status           AS status,
94
                       hash             AS hash,
95
                       token_expires_on AS tokenEndOfLife
96
                  FROM {$this->table}
97
                 WHERE token = :token
98
                   AND token_action = :action
99
                   AND token_expires_on > :expires";
100
101
        $statement = $this->connection->prepare($sql);
102
103
        $statement->bindValue(':token', $entity->getToken());
104
        $statement->bindValue(':action', $entity->getTokenAction());
105
        $statement->bindValue(':expires', $entity->getTokenEndOfLife());
106
107
        $statement->execute();
108
109
        $data = $statement->fetch();
110
111
        if ($data) {
112
            $this->applyValues($entity, $data);
113
        }
114
    }
115
}
116

src/Palladium/Mapper/EmailIdentity.php 1 location

@@ 45-72 (lines=28) @@
42
    /**
43
     * @param Entity\EmailIdentity $entity
44
     */
45
    public function fetch(Entity\EmailIdentity $entity)
46
    {
47
        $sql = "SELECT identity_id      AS id,
48
                       account_id       AS accountId,
49
                       hash             AS hash,
50
                       status           AS status,
51
                       token            AS token,
52
                       token_action     AS tokenAction,
53
                       token_expires_on AS tokenEndOfLife
54
                  FROM {$this->table}
55
                 WHERE type = :type
56
                   AND fingerprint = :fingerprint
57
                   AND identifier = :email";
58
59
        $statement = $this->connection->prepare($sql);
60
61
        $statement->bindValue(':type', $entity->getType());
62
        $statement->bindValue(':email', $entity->getEmailAddress());
63
        $statement->bindValue(':fingerprint', $entity->getFingerprint());
64
65
        $statement->execute();
66
67
        $data = $statement->fetch();
68
69
        if ($data) {
70
            $this->applyValues($entity, $data);
71
        }
72
    }
73
74
75
    /**

src/Palladium/Mapper/NonceIdentity.php 1 location

@@ 18-43 (lines=26) @@
15
    /**
16
     * @param Entity\NonceIdentity $entity
17
     */
18
    public function fetch(Entity\NonceIdentity $entity)
19
    {
20
        $status = Entity\Identity::STATUS_ACTIVE;
21
22
        $sql = "SELECT identity_id      AS id,
23
                       account_id       AS accountId,
24
                       hash             AS hash,
25
                       status           AS status
26
                  FROM {$this->table}
27
                 WHERE type = :type
28
                   AND status = {$status}
29
                   AND identifier = :nonce";
30
31
        $statement = $this->connection->prepare($sql);
32
33
        $statement->bindValue(':nonce', $entity->getIdentifier());
34
        $statement->bindValue(':type', $entity->getType());
35
36
        $statement->execute();
37
38
        $data = $statement->fetch();
39
40
        if ($data) {
41
            $this->applyValues($entity, $data);
42
        }
43
    }
44
45
46
    /**