1 | <?php |
||
7 | abstract class Claim implements ClaimInterface |
||
8 | { |
||
9 | /** |
||
10 | * The claim name |
||
11 | * |
||
12 | * @var string |
||
13 | */ |
||
14 | protected $name; |
||
15 | |||
16 | /** |
||
17 | * The claim value |
||
18 | * |
||
19 | * @var mixed |
||
20 | */ |
||
21 | private $value; |
||
22 | |||
23 | /** |
||
24 | * @param mixed $value |
||
25 | */ |
||
26 | 66 | public function __construct($value) |
|
30 | |||
31 | /** |
||
32 | * Set the claim value, and call a validate method if available |
||
33 | * |
||
34 | * @param $value |
||
35 | * @throws \Tymon\JWTAuth\Exceptions\InvalidClaimException |
||
36 | * @return $this |
||
37 | */ |
||
38 | 66 | public function setValue($value) |
|
48 | |||
49 | /** |
||
50 | * Get the claim value |
||
51 | * |
||
52 | * @return mixed |
||
53 | */ |
||
54 | 66 | public function getValue() |
|
58 | |||
59 | /** |
||
60 | * Set the claim name |
||
61 | * |
||
62 | * @param string $name |
||
63 | * @return $this |
||
64 | */ |
||
65 | 6 | public function setName($name) |
|
71 | |||
72 | /** |
||
73 | * Get the claim name |
||
74 | * |
||
75 | * @return string |
||
76 | */ |
||
77 | 66 | public function getName() |
|
81 | |||
82 | /** |
||
83 | * Validate the Claim value |
||
84 | * |
||
85 | * @param $value |
||
86 | * @return boolean |
||
87 | */ |
||
88 | 66 | protected function validate($value) |
|
92 | |||
93 | /** |
||
94 | * Build a key value array comprising of the claim name and value |
||
95 | * |
||
96 | * @return array |
||
97 | */ |
||
98 | public function toArray() |
||
102 | |||
103 | /** |
||
104 | * Get the claim as a string |
||
105 | * |
||
106 | * @return string |
||
107 | */ |
||
108 | public function __toString() |
||
112 | } |
||
113 |