Code Duplication    Length = 18-18 lines in 2 locations

src/Xtools/UserRepository.php 2 locations

@@ 41-58 (lines=18) @@
38
     * @param string $username The username to find.
39
     * @return int
40
     */
41
    public function getId($databaseName, $username)
42
    {
43
        $cacheKey = $this->getCacheKey(func_get_args(), 'user_id');
44
        if ($this->cache->hasItem($cacheKey)) {
45
            return $this->cache->getItem($cacheKey)->get();
46
        }
47
48
        $userTable = $this->getTableName($databaseName, 'user');
49
        $sql = "SELECT user_id FROM $userTable WHERE user_name = :username LIMIT 1";
50
        $resultQuery = $this->getProjectsConnection()->prepare($sql);
51
        $resultQuery->bindParam('username', $username);
52
        $resultQuery->execute();
53
        $userId = (int)$resultQuery->fetchColumn();
54
55
        // Cache for 10 minutes and return.
56
        $this->setCache($cacheKey, $userId);
57
        return $userId;
58
    }
59
60
    /**
61
     * Get the user's registration date.
@@ 66-83 (lines=18) @@
63
     * @param string $username The username to find.
64
     * @return string|null As returned by the database.
65
     */
66
    public function getRegistrationDate($databaseName, $username)
67
    {
68
        $cacheKey = $this->getCacheKey(func_get_args(), 'user_registration');
69
        if ($this->cache->hasItem($cacheKey)) {
70
            return $this->cache->getItem($cacheKey)->get();
71
        }
72
73
        $userTable = $this->getTableName($databaseName, 'user');
74
        $sql = "SELECT user_registration FROM $userTable WHERE user_name = :username LIMIT 1";
75
        $resultQuery = $this->getProjectsConnection()->prepare($sql);
76
        $resultQuery->bindParam('username', $username);
77
        $resultQuery->execute();
78
        $registrationDate = $resultQuery->fetchColumn();
79
80
        // Cache and return.
81
        $this->setCache($cacheKey, $registrationDate);
82
        return $registrationDate;
83
    }
84
85
    /**
86
     * Get the user's (system) edit count.