VolunteerProfile::userInEmailList()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 11
rs 10
1
<?php
2
/**
3
 * A class to abstract access to a Volunter System Profile.
4
 *
5
 * This class is the primary method to access volunteer information.
6
 * 
7
 * @property string $uid The user's ID
8
 * @property string $email The user's email address
9
 * @property string $lastName The user's surname (last name)
10
 * @property string $firstName The user's given name (first name)
11
 * @property string $burnerName The user's nick name
12
 * @property array $certs Certifications possesed by the user
13
 */
14
class VolunteerProfile extends VolunteerObject
15
{
16
    protected $dbData;
17
18
    public function __construct($uid, $dbData = null)
19
    {
20
        if($uid === '/dev/null')
21
        {
22
            return;
23
        }
24
        parent::__construct($uid, $dbData, 'participants', 'uid');
25
    }
26
27
    public function __get($propName)
28
    {
29
        switch($propName)
30
        {
31
            case 'certs':
32
                if(!isset($this->dbData['certs']))
33
                {
34
                    return array();
35
                }
36
                return $this->dbData['certs'];
37
            default:
38
                return $this->dbData[$propName];
39
        }
40
    }
41
42
    public function getDisplayName($type = 'webName')
43
    {
44
        switch($this->dbData[$type])
45
        {
46
            case 'anonymous':
47
                return 'Anonymous';
48
            case 'full':
49
                return $this->dbData['firstName'].' "'.$this->dbData['burnerName'].'" '.$this->dbData['lastName'];
50
            case 'burnerLast':
51
                return $this->dbData['burnerName'].' '.$this->dbData['lastName'];
52
            case 'firstBurner':
53
                return $this->dbData['firstName'].' '.$this->dbData['burnerName'];
54
            case 'burner':
55
                return $this->dbData['burnerName'];
56
        }
57
    }
58
59
    public function isEEAvailable()
60
    {
61
        return isset($this->dbData['firstName']) && isset($this->dbData['lastName']);
62
    }
63
64
    public function userInEmailList($list)
65
    {
66
        if(!isset($this->dbData['email']))
67
        {
68
            return false;
69
        }
70
        if(in_array($this->dbData['email'], $list))
71
        {
72
            return true;
73
        }
74
        return false;
75
    }
76
}
77