Code Duplication    Length = 26-28 lines in 2 locations

src/Palladium/Mapper/EmailIdentity.php 1 location

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

src/Palladium/Mapper/Identity.php 1 location

@@ 71-96 (lines=26) @@
68
    }
69
70
71
    private function fetchByToken(Entity\Identity $entity)
72
    {
73
        $sql = "SELECT identity_id      AS id,
74
                       parent_id        AS parentId,
75
                       account_id       AS accountId,
76
                       status           AS status,
77
                       hash             AS hash,
78
                       token_expires_on AS tokenEndOfLife
79
                  FROM {$this->table}
80
                 WHERE token = :token
81
                   AND token_action = :action
82
                   AND token_expires_on > :expires";
83
84
        $statement = $this->connection->prepare($sql);
85
86
        $statement->bindValue(':token', $entity->getToken());
87
        $statement->bindValue(':action', $entity->getTokenAction());
88
        $statement->bindValue(':expires', $entity->getTokenEndOfLife());
89
90
        $statement->execute();
91
92
        $data = $statement->fetch();
93
94
        if ($data) {
95
            $this->applyValues($entity, $data);
96
        }
97
    }
98
}
99