Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
| ResourceOwner | |
0.00% |
0 / 9 |
|
0.00% |
0 / 6 |
132 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
| getEmail | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
| getVerifiedEmail | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| getName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
| toArray | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace BO\Slim\Middleware\OAuth\Keycloak; |
| 4 | |
| 5 | use Stevenmaguire\OAuth2\Client\Provider\KeycloakResourceOwner; |
| 6 | |
| 7 | class ResourceOwner extends KeycloakResourceOwner |
| 8 | { |
| 9 | /** |
| 10 | * Raw response |
| 11 | * |
| 12 | * @var array |
| 13 | */ |
| 14 | protected $response; |
| 15 | |
| 16 | /** |
| 17 | * Creates new resource owner. |
| 18 | * |
| 19 | * @param array $response |
| 20 | */ |
| 21 | public function __construct(array $response = array()) |
| 22 | { |
| 23 | $this->response = $response; |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * Get resource owner id |
| 28 | * |
| 29 | * @return string|null |
| 30 | */ |
| 31 | public function getId() |
| 32 | { |
| 33 | return \array_key_exists('sub', $this->response) ? $this->response['sub'] : null; |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Get resource owner email |
| 38 | * |
| 39 | * @return string|null |
| 40 | */ |
| 41 | public function getEmail() |
| 42 | { |
| 43 | return \array_key_exists('email', $this->response) ? $this->response['email'] : null; |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Get verified resource owner email |
| 48 | * |
| 49 | * @return string|null |
| 50 | */ |
| 51 | public function getVerifiedEmail() |
| 52 | { |
| 53 | $email = null; |
| 54 | if (\array_key_exists('email_verified', $this->response) && $this->response['email_verified']) { |
| 55 | $email = $this->getEmail(); |
| 56 | } |
| 57 | return $email; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Get resource owner name |
| 62 | * |
| 63 | * @return string|null |
| 64 | */ |
| 65 | public function getName() |
| 66 | { |
| 67 | return \array_key_exists('preferred_username', $this->response) ? $this->response['preferred_username'] : null; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Return all of the owner details available as an array. |
| 72 | * |
| 73 | * @return array |
| 74 | */ |
| 75 | public function toArray() |
| 76 | { |
| 77 | return $this->response; |
| 78 | } |
| 79 | } |