Code Duplication    Length = 13-14 lines in 3 locations

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

@@ 1495-1508 (lines=14) @@
1492
 * @return array $user_info array user_id, lastname, firstname, username, email
1493
 * @author Yannick Warnier <[email protected]>
1494
 */
1495
function api_get_user_info_from_username($username = '')
1496
{
1497
    if (empty($username)) {
1498
        return false;
1499
    }
1500
    $username = trim($username);
1501
1502
1503
    $user = UserManager::getManager()->findUserByUsername($username);
1504
    if ($user) {
1505
        return _api_format_user($user);
1506
    }
1507
    return false;
1508
}
1509
1510
/**
1511
 * Get first user with an email
@@ 1515-1527 (lines=13) @@
1512
 * @param string $email
1513
 * @return array|bool
1514
 */
1515
function api_get_user_info_from_email($email)
1516
{
1517
    if (empty($email)) {
1518
        return false;
1519
    }
1520
1521
    $user = UserManager::getManager()->findUserByEmail($email);
1522
    if ($user) {
1523
        return _api_format_user($user);
1524
    }
1525
1526
    return false;
1527
}
1528
1529
/**
1530
 * @return string
@@ 7223-7235 (lines=13) @@
7220
 * @return array $user_info user_id, lastname, firstname, username, email, ...
7221
 * @author Yannick Warnier <[email protected]>
7222
 */
7223
function api_get_user_info_from_official_code($officialCode)
7224
{
7225
    if (empty($officialCode)) {
7226
        return false;
7227
    }
7228
7229
    $user = UserManager::getManager()->findUserByOfficialCode($officialCode);
7230
    if ($user) {
7231
        return _api_format_user($user);
7232
    }
7233
7234
    return false;
7235
}
7236
7237
/**
7238
 * @param string $usernameInputId