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.

Zips   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 71
Duplicated Lines 11.27 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 8
loc 71
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 8 8 1
A list() 0 4 1
A get() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Mozammil\Putio\Endpoints;
4
5
use Mozammil\Putio\Http\Client;
6
7
class Zips
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
     * Creates zip file for given files.
23
     * A zip_id is returned to keep track
24
     * of the status of zip creation process.
25
     *
26
     * @param array $file_ids
27
     *
28
     * @throws \GuzzleHttp\Exception\GuzzleException
29
     *
30
     * @see https://api.put.io/v2/docs/zips.html#post--zips-create
31
     *
32
     * @return string
33
     */
34 View Code Duplication
    public function create(array $file_ids = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
35
    {
36
        return $this->client->post('zips/create', [
37
            'form_params' => [
38
                'file_ids' => implode(',', $file_ids),
39
            ],
40
        ]);
41
    }
42
43
    /**
44
     * Lists active zip files.
45
     *
46
     * @throws \GuzzleHttp\Exception\GuzzleException
47
     *
48
     * @see https://api.put.io/v2/docs/zips.html#get--zips-list
49
     *
50
     * @return string
51
     */
52
    public function list()
53
    {
54
        return $this->client->get('zips/list');
55
    }
56
57
    /**
58
     * Gives detailed information about the give zip file id.
59
     * Check the zip creation process status with your zip_id.
60
     * When the process is done, you will get url value along
61
     * with size and missing_files.
62
     * You might need to poll this end point
63
     * until you get an url value.
64
     * missing_files is an array of file names
65
     * which are not included into the zip file for some reason.
66
     *
67
     * @throws \GuzzleHttp\Exception\GuzzleException
68
     *
69
     * @see https://api.put.io/v2/docs/zips.html#get-zip
70
     *
71
     * @return string
72
     */
73
    public function get(int $zip_id)
74
    {
75
        return $this->client->get(sprintf('zips/%d', $zip_id));
76
    }
77
}
78