MappedUser::vendorName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
/**
3
 * @author Tharanga Kothalawala <[email protected]>
4
 * @date 30-12-2018
5
 */
6
7
namespace TSK\SSO\Storage;
8
9
/**
10
 * @internal
11
 * @package TSK\SSO\Storage
12
 * @see \TSK\SSO\AppUser\AppUser
13
 * @see \TSK\SSO\ThirdParty\ThirdPartyUser
14
 *
15
 * This represent a mapping between the third party user(ThirdPartyUser) with the client application user(AppUser).
16
 * This object is only created within the library and is readonly.
17
 */
18
class MappedUser
19
{
20
    /**
21
     * @var string
22
     */
23
    private $appUserId;
24
25
    /**
26
     * @var string
27
     */
28
    private $vendorName;
29
30
    /**
31
     * @var string
32
     */
33
    private $vendorEmail;
34
35
    /**
36
     * @var string
37
     */
38
    private $vendorToken;
39
40
    /**
41
     * @var string
42
     */
43
    private $vendorData;
44
45
    /**
46
     * @param string $appUserId application's use id. ex: can be a UUID or an integer
47
     * @param string $vendorName name of the vendor. ex: Google, Facebook, LinkedIn
48
     * @param string $vendorEmail user's email address at third party vendor's end
49
     * @param string $vendorToken
50
     * @param string $vendorData JSON encoded vendor user extra data.
51
     */
52 7
    public function __construct($appUserId, $vendorName, $vendorEmail, $vendorToken, $vendorData)
53
    {
54 7
        $this->appUserId = $appUserId;
55 7
        $this->vendorName = $vendorName;
56 7
        $this->vendorEmail = $vendorEmail;
57 7
        $this->vendorToken = $vendorToken;
58 7
        $this->vendorData = $vendorData;
59 7
    }
60
61
    /**
62
     * @return string
63
     */
64 3
    public function appUserId()
65
    {
66 3
        return $this->appUserId;
67
    }
68
69
    /**
70
     * @return string
71
     */
72 4
    public function vendorName()
73
    {
74 4
        return $this->vendorName;
75
    }
76
77
    /**
78
     * @return string
79
     */
80 5
    public function vendorEmail()
81
    {
82 5
        return $this->vendorEmail;
83
    }
84
85
    /**
86
     * @return string
87
     */
88 4
    public function vendorToken()
89
    {
90 4
        return $this->vendorToken;
91
    }
92
93
    /**
94
     * @return string
95
     */
96 2
    public function vendorData()
97
    {
98 2
        return $this->vendorData;
99
    }
100
101
    /**
102
     * @return array
103
     */
104 2
    public function decodedVendorData()
105
    {
106 2
        $decoded = @json_decode($this->vendorData(), true);
107 2
        if ($decoded === null && json_last_error() !== JSON_ERROR_NONE) {
108
            return array();
109
        }
110
111 2
        return $decoded;
112
    }
113
}
114