Completed
Push — master ( 5db87b...2ca7c0 )
by Stephen
02:42
created

OrgMember::profile()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 4.679

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 10
ccs 3
cts 7
cp 0.4286
rs 9.4285
c 1
b 0
f 1
cc 3
eloc 6
nc 3
nop 0
crap 4.679
1
<?php
2
3
namespace StarCitizen\Models;
4
5
use StarCitizen\Accounts\Accounts;
6
7
/**
8
 * Class OrgMember
9
 *
10
 * @package StarCitizen\Models
11
 *
12
 * @property Profile $profile
13
 */
14
class OrgMember extends Model
15
{
16
    /**
17
     * Member vars
18
     */
19
    public $sid;
20
    public $handle;
21
    public $rank;
22
    public $stars;
23
    public $roles;
24
    public $type;
25
    public $visibility;
26
27
    /**
28
     * @var array
29
     */
30
    protected $magicProperties = [
31
        'profile'
32
    ];
33
34
    /**
35
     * @var Profile
36
     */
37
    private $profile;
38
39
40
    /**
41
     * OrgMember constructor.
42
     *
43
     * @param array $memberData
44
     */
45 3
    public function __construct(array $memberData)
46
    {
47 3
        foreach ($memberData as $key => $value) {
48 3
            $this->$key = $value;
49 3
        }
50 3
    }
51
52
    /**
53
     * @return Profile
54
     */
55 1
    final protected function profile()
56
    {
57 1
        if ($this->profile === null) {
58 1
            $profile = Accounts::findProfile($this->handle);
59
            if ($profile instanceof Profile)
60
                $this->profile = $profile;
61
        }
62
63
        return $this->profile;
64
    }
65
}