GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 190bf2...86e13d )
by Mozammil
01:11
created

Account   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 80
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A info() 0 4 1
A settings() 0 4 1
A update() 0 23 4
1
<?php
2
3
namespace Mozammil\Putio\Endpoints;
4
5
use Mozammil\Putio\Http\Client;
6
7
class Account
8
{
9
    /**
10
     * The Http Client.
11
     *
12
     * @var \Mozammil\Putio\Http\Client
13
     */
14
    protected $client;
15
16
    public function __construct(Client $client)
17
    {
18
        $this->client = $client;
19
    }
20
21
    /**
22
     * Information about user account.
23
     * subtitle_languages is a list of ISO639-2 codes.
24
     *
25
     * @throws \GuzzleHttp\Exception\GuzzleException
26
     *
27
     * @see https://api.put.io/v2/docs/account.html#get--account-info
28
     *
29
     * @return string
30
     */
31
    public function info()
32
    {
33
        return $this->client->get('account/info');
34
    }
35
36
    /**
37
     * User preferences.
38
     *
39
     * @throws \GuzzleHttp\Exception\GuzzleException
40
     *
41
     * @see https://api.put.io/v2/docs/account.html#get--account-settings
42
     *
43
     * @return string
44
     */
45
    public function settings()
46
    {
47
        return $this->client->get('account/settings');
48
    }
49
50
    /**
51
     * Updates user preferences. Only sent parameters are updated.
52
     *
53
     * @param int $default_download_folder
54
     * @param bool $is_invisible
55
     * @param array $subtitle_languages
56
     *
57
     * @throws \GuzzleHttp\Exception\GuzzleException
58
     *
59
     * @see https://api.put.io/v2/docs/account.html#post--account-settings
60
     *
61
     * @return string
62
     */
63
    public function update(
64
        int $default_download_folder = null,
65
        bool $is_invisible = null,
66
        array $subtitle_languages = []
67
    ) {
68
        $params = [];
69
70
        if ($default_download_folder) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $default_download_folder of type null|integer is loosely compared to true; this is ambiguous if the integer can be zero. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For integer values, zero is a special case, in particular the following results might be unexpected:

0   == false // true
0   == null  // true
123 == false // false
123 == null  // false

// It is often better to use strict comparison
0 === false // false
0 === null  // false
Loading history...
71
            $params['default_download_folder'] = $default_download_folder;
72
        }
73
74
        if ($is_invisible) {
75
            $params['is_invisible'] = $is_invisible;
76
        }
77
78
        if (count($subtitle_languages)) {
79
            $params['subtitle_languages'] = implode(',', $subtitle_languages);
80
        }
81
82
        return $this->client->post('account/settings', [
83
            'form_params' => $params,
84
        ]);
85
    }
86
}
87