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