PersonalAccessTokenResult   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 55
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A toArray() 0 7 1
A toJson() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Rinvex\Oauth;
6
7
use Illuminate\Contracts\Support\Jsonable;
8
use Illuminate\Contracts\Support\Arrayable;
9
10
class PersonalAccessTokenResult implements Arrayable, Jsonable
11
{
12
    /**
13
     * The access token.
14
     *
15
     * @var string
16
     */
17
    public $accessToken;
18
19
    /**
20
     * The token model instance.
21
     *
22
     * @var \Rinvex\Oauth\Models\AccessToken
23
     */
24
    public $token;
25
26
    /**
27
     * Create a new result instance.
28
     *
29
     * @param string                           $accessToken
30
     * @param \Rinvex\Oauth\Models\AccessToken $token
31
     *
32
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
33
     */
34
    public function __construct($accessToken, $token)
35
    {
36
        $this->token = $token;
37
        $this->accessToken = $accessToken;
38
    }
39
40
    /**
41
     * Get the instance as an array.
42
     *
43
     * @return array
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use array<string,string|Models\AccessToken>.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
44
     */
45
    public function toArray()
46
    {
47
        return [
48
            'accessToken' => $this->accessToken,
49
            'token' => $this->token,
50
        ];
51
    }
52
53
    /**
54
     * Convert the object to its JSON representation.
55
     *
56
     * @param int $options
57
     *
58
     * @return string
59
     */
60
    public function toJson($options = 0)
61
    {
62
        return json_encode($this->toArray(), $options);
63
    }
64
}
65