MongoUser::moodleId()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * @author  Xavier Chopin <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace App\Model;
11
12
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
13
14
class MongoUser extends Eloquent {
15
16
    protected $collection = 'mongoUser';
17
18
    protected $primaryKey = 'user.userId';
19
20
    /**
21
     * Returns the Moodle id for a LDAP uid given.
22
     *
23
     * @param $uid
24
     * @return mixed
25
     */
26
    public static function moodleId($uid)
27
    {
28
        $user = MongoUser::find($uid);
29
        return $user == null ? null : $user->user['sourcedId'];
30
    }
31
32
33
}
34
35
36