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

TokenSchema   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 20
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 4 1
A getAttributes() 0 6 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