-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathASPayload.php
More file actions
44 lines (34 loc) · 1.11 KB
/
Copy pathASPayload.php
File metadata and controls
44 lines (34 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace AppleSignIn;
use Exception;
/**
* A class decorator for the Sign In with Apple payload produced by
* decoding the signed JWT from a client.
*/
class ASPayload {
protected $_instance;
public function __construct(?\stdClass $instance) {
if(is_null($instance)) {
throw new Exception('ASPayload received null instance.');
}
$this->_instance = $instance;
}
public function __call($method, $args) {
return call_user_func_array(array($this->_instance, $method), $args);
}
public function __get($key) {
return (isset($this->_instance->$key)) ? $this->_instance->$key : null;
}
public function __set($key, $val) {
return $this->_instance->$key = $val;
}
public function getEmail() : ?string {
return (isset($this->_instance->email)) ? $this->_instance->email : null;
}
public function getUser() : ?string {
return (isset($this->_instance->sub)) ? $this->_instance->sub : null;
}
public function verifyUser(string $user) : bool {
return $user === $this->getUser();
}
}