Code Duplication    Length = 13-14 lines in 3 locations

main/inc/lib/api.lib.php 3 locations

@@ 1486-1499 (lines=14) @@
1483
 * @return array $user_info array user_id, lastname, firstname, username, email
1484
 * @author Yannick Warnier <[email protected]>
1485
 */
1486
function api_get_user_info_from_username($username = '')
1487
{
1488
    if (empty($username)) {
1489
        return false;
1490
    }
1491
    $username = trim($username);
1492
1493
1494
    $user = UserManager::getManager()->findUserByUsername($username);
1495
    if ($user) {
1496
        return _api_format_user($user);
1497
    }
1498
    return false;
1499
}
1500
1501
/**
1502
 * Get first user with an email
@@ 1506-1518 (lines=13) @@
1503
 * @param string $email
1504
 * @return array|bool
1505
 */
1506
function api_get_user_info_from_email($email)
1507
{
1508
    if (empty($email)) {
1509
        return false;
1510
    }
1511
1512
    $user = UserManager::getManager()->findUserByEmail($email);
1513
    if ($user) {
1514
        return _api_format_user($user);
1515
    }
1516
1517
    return false;
1518
}
1519
1520
/**
1521
 * @return string
@@ 7155-7167 (lines=13) @@
7152
 * @return array $user_info user_id, lastname, firstname, username, email, ...
7153
 * @author Yannick Warnier <[email protected]>
7154
 */
7155
function api_get_user_info_from_official_code($officialCode)
7156
{
7157
    if (empty($officialCode)) {
7158
        return false;
7159
    }
7160
7161
    $user = UserManager::getManager()->findUserByOfficialCode($officialCode);
7162
    if ($user) {
7163
        return _api_format_user($user);
7164
    }
7165
7166
    return false;
7167
}
7168
7169
/**
7170
 * @param string $usernameInputId