Completed
Push — develop ( 291211...8d06e7 )
by Ando
11:36
created

TokenSchema::getAttributes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
namespace App\Schemas;
3
4
use Neomerx\JsonApi\Schema\SchemaProvider;
5
use Tymon\JWTAuth\Facades\JWTAuth;
6
7
class TokenSchema extends SchemaProvider
8
{
9
    protected $resourceType = 'tokens';
10
11
    /**
12
     * @param object $token
13
     * @return mixed
14
     */
15
    public function getId($token) : string
16
    {
17
        return JWTAuth::getPayload($token)->getJwtId();
18
    }
19
20
    public function getAttributes($token) : array
21
    {
22
        return [
23
            'token' => $token->get()
24
        ];
25
    }
26
}
27