datlechin /
oauth2-sepay
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Datlechin\OAuth2\Client\Provider; |
||
| 6 | |||
| 7 | use League\OAuth2\Client\Provider\ResourceOwnerInterface; |
||
| 8 | use League\OAuth2\Client\Tool\ArrayAccessorTrait; |
||
| 9 | |||
| 10 | class SePayResourceOwner implements ResourceOwnerInterface |
||
| 11 | { |
||
| 12 | use ArrayAccessorTrait; |
||
| 13 | |||
| 14 | protected array $data; |
||
| 15 | |||
| 16 | public function __construct(array $response) |
||
| 17 | { |
||
| 18 | $this->data = $response['data']; |
||
| 19 | } |
||
| 20 | |||
| 21 | public function getId(): int |
||
| 22 | { |
||
| 23 | return $this->getValueByKey($this->data, 'id'); |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 24 | } |
||
| 25 | |||
| 26 | public function getEmail(): string |
||
| 27 | { |
||
| 28 | return $this->getValueByKey($this->data, 'email'); |
||
|
0 ignored issues
–
show
|
|||
| 29 | } |
||
| 30 | |||
| 31 | public function getName(): string |
||
| 32 | { |
||
| 33 | return sprintf( |
||
| 34 | '%s %s', |
||
| 35 | $this->getFirstName(), |
||
| 36 | $this->getLastName() |
||
| 37 | ); |
||
| 38 | } |
||
| 39 | |||
| 40 | public function getFirstName(): string |
||
| 41 | { |
||
| 42 | return $this->getValueByKey($this->data, 'first_name'); |
||
|
0 ignored issues
–
show
|
|||
| 43 | } |
||
| 44 | |||
| 45 | public function getLastName(): string |
||
| 46 | { |
||
| 47 | return $this->getValueByKey($this->data, 'last_name'); |
||
|
0 ignored issues
–
show
|
|||
| 48 | } |
||
| 49 | |||
| 50 | public function getAvatarUrl(): string |
||
| 51 | { |
||
| 52 | return $this->getValueByKey($this->data, 'avatar'); |
||
|
0 ignored issues
–
show
|
|||
| 53 | } |
||
| 54 | |||
| 55 | public function getPhone(): string |
||
| 56 | { |
||
| 57 | return $this->getValueByKey($this->data, 'phone'); |
||
|
0 ignored issues
–
show
|
|||
| 58 | } |
||
| 59 | |||
| 60 | public function toArray(): array |
||
| 61 | { |
||
| 62 | return $this->data; |
||
| 63 | } |
||
| 64 | } |
||
| 65 |