NewAccessToken.php
1.3 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
namespace Laravel\Sanctum;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Jsonable;
class NewAccessToken implements Arrayable, Jsonable
{
/**
* The access token instance.
*
* @var \Laravel\Sanctum\PersonalAccessToken
*/
public $accessToken;
/**
* The plain text version of the token.
*
* @var string
*/
public $plainTextToken;
/**
* Create a new access token result.
*
* @param \Laravel\Sanctum\PersonalAccessToken $accessToken
* @param string $plainTextToken
* @return void
*/
public function __construct(PersonalAccessToken $accessToken, string $plainTextToken)
{
$this->accessToken = $accessToken;
$this->plainTextToken = $plainTextToken;
}
/**
* Get the instance as an array.
*
* @return array
*/
public function toArray()
{
return [
'accessToken' => $this->accessToken,
'plainTextToken' => $this->plainTextToken,
];
}
/**
* Convert the object to its JSON representation.
*
* @param int $options
* @return string
*/
public function toJson($options = 0)
{
return json_encode($this->toArray(), $options);
}
}