Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
19 / 19 |
|
100.00% |
8 / 8 |
CRAP | |
100.00% |
1 / 1 |
| User | |
100.00% |
19 / 19 |
|
100.00% |
8 / 8 |
8 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
| getUniqueKey | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getUserName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getDisplayName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getAvatar | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getProviderFQCN | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getRawData | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| __set_state | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Miniframe\SocialLogin\Model; |
| 4 | |
| 5 | class User |
| 6 | { |
| 7 | /** |
| 8 | * The primary key from the social login service. |
| 9 | * |
| 10 | * @var string |
| 11 | */ |
| 12 | protected $uniqueKey; |
| 13 | /** |
| 14 | * The username. |
| 15 | * |
| 16 | * @var string |
| 17 | */ |
| 18 | protected $userName; |
| 19 | /** |
| 20 | * The display name. |
| 21 | * |
| 22 | * @var string |
| 23 | */ |
| 24 | protected $displayName; |
| 25 | /** |
| 26 | * Avatar URL (can be a gravatar URL). |
| 27 | * |
| 28 | * @var string |
| 29 | */ |
| 30 | protected $avatar; |
| 31 | /** |
| 32 | * The fully qualified classname of the login provider. |
| 33 | * |
| 34 | * @var string |
| 35 | */ |
| 36 | protected $providerFQCN; |
| 37 | /** |
| 38 | * Raw data. |
| 39 | * |
| 40 | * @var array |
| 41 | */ |
| 42 | protected $rawData; |
| 43 | |
| 44 | /** |
| 45 | * Creates a new User instance |
| 46 | * |
| 47 | * @param string $uniqueKey The primary key from the social login service. |
| 48 | * @param string $userName The username. |
| 49 | * @param string $displayName The display name. |
| 50 | * @param string $avatar Avatar URL (can be a gravatar URL). |
| 51 | * @param string $providerFQCN The fully qualified classname of the login provider. |
| 52 | * @param array $rawData Raw data. |
| 53 | */ |
| 54 | public function __construct( |
| 55 | string $uniqueKey, |
| 56 | string $userName, |
| 57 | string $displayName, |
| 58 | string $avatar, |
| 59 | string $providerFQCN, |
| 60 | array $rawData |
| 61 | ) { |
| 62 | $this->uniqueKey = $uniqueKey; |
| 63 | $this->userName = $userName; |
| 64 | $this->displayName = $displayName; |
| 65 | $this->avatar = $avatar; |
| 66 | $this->providerFQCN = $providerFQCN; |
| 67 | $this->rawData = $rawData; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Returns the primary key from the social login service. |
| 72 | * |
| 73 | * @return string |
| 74 | */ |
| 75 | public function getUniqueKey(): string |
| 76 | { |
| 77 | return $this->uniqueKey; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Returns the username. |
| 82 | * |
| 83 | * @return string |
| 84 | */ |
| 85 | public function getUserName(): string |
| 86 | { |
| 87 | return $this->userName; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Returns the display name. |
| 92 | * |
| 93 | * @return string |
| 94 | */ |
| 95 | public function getDisplayName(): string |
| 96 | { |
| 97 | return $this->displayName; |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * Returns the avatar URL (can be a gravatar URL). |
| 102 | * |
| 103 | * @return string |
| 104 | */ |
| 105 | public function getAvatar(): string |
| 106 | { |
| 107 | return $this->avatar; |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * Returns the fully qualified classname of the login provider. |
| 112 | * |
| 113 | * @return string |
| 114 | */ |
| 115 | public function getProviderFQCN(): string |
| 116 | { |
| 117 | return $this->providerFQCN; |
| 118 | } |
| 119 | |
| 120 | /** |
| 121 | * Returns the raw data. |
| 122 | * |
| 123 | * @return array |
| 124 | */ |
| 125 | public function getRawData(): array |
| 126 | { |
| 127 | return $this->rawData; |
| 128 | } |
| 129 | |
| 130 | /** |
| 131 | * Returns a user object with a specific state (makes this object serializable with var_export) |
| 132 | * |
| 133 | * @param array $properties The list of properties. |
| 134 | * |
| 135 | * @return User |
| 136 | */ |
| 137 | public static function __set_state(array $properties): User |
| 138 | { |
| 139 | return new User( |
| 140 | $properties['uniqueKey'], |
| 141 | $properties['userName'], |
| 142 | $properties['displayName'], |
| 143 | $properties['avatar'], |
| 144 | $properties['providerFQCN'], |
| 145 | $properties['rawData'] |
| 146 | ); |
| 147 | } |
| 148 | } |