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.
Passed
Push — master ( 579a75...556562 )
by Casper
03:43 queued 01:48
created

FilesClient   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Test Coverage

Coverage 91.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 24
c 1
b 0
f 0
dl 0
loc 71
rs 10
ccs 22
cts 24
cp 0.9167
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A store() 0 15 2
A storeWithPath() 0 25 2
1
<?php
2
3
namespace NStack\Clients;
4
5
use DateTime;
6
use NStack\Exceptions\FailedToParseException;
7
use NStack\Models\File;
8
9
/**
10
 * Class FilesClient
11
 *
12
 * @package NStack\Clients
13
 * @author  Tiago Araujo <[email protected]>
14
 */
15
class FilesClient extends NStackClient
16
{
17
    /** @var string */
18
    protected $path = 'content/files';
19
20
    /**
21
     * store
22
     *
23
     * @param String $name
24
     * @param array $tagsArray
25
     * @param DateTime $goneAt
26
     * @param String $privacy
27
     * @param String $imagePath
28
     * @return File
29
     * @throws FailedToParseException
30
     */
31 1
    public function store(String $name, String $privacy, String $imagePath, array $tagsArray = null, DateTime $goneAt = null)
32
    {
33 1
        $response = $this->client->post($this->buildPath($this->path), [
34
            'form_params' => [
35 1
                'name'      => $name,
36 1
                'tags'      => is_null($tagsArray) ? null : implode(",", $tagsArray),
37 1
                'gone_at'   => $goneAt,
38 1
                'privacy'   => $privacy,
39 1
                'file'      => fopen($imagePath, 'r'),
40
            ]
41
        ]);
42 1
        $contents = $response->getBody()->getContents();
43 1
        $data = json_decode($contents, true);
44
45 1
        return new File($data['data']);
46
    }
47
48
    /**
49
     * storeWithPath
50
     *
51
     * @param String $name
52
     * @param String $privacy
53
     * @param String $path
54
     * @param String $mime
55
     * @param int $size
56
     * @param array|null $tagsArray
57
     * @param DateTime|null $goneAt
58
     * @return File
59
     * @throws FailedToParseException
60
     */
61 1
    public function storeWithPath(
62
        String $name,
63
        String $privacy,
64
        String $path,
65
        String $mime,
66
        int $size,
67
        array $tagsArray = null,
68
        DateTime $goneAt = null
69
    )
70
    {
71 1
        $response = $this->client->post($this->buildPath($this->path . '/path'), [
72
            'form_params' => [
73 1
                'name'      => $name,
74 1
                'tags'      => is_null($tagsArray) ? null : implode(",", $tagsArray),
75 1
                'gone_at'   => $goneAt,
76 1
                'privacy'   => $privacy,
77 1
                'path'      => $path,
78 1
                'mime'      => $mime,
79 1
                'size'      => $size,
80
            ]
81
        ]);
82 1
        $contents = $response->getBody()->getContents();
83 1
        $data = json_decode($contents, true);
84
85 1
        return new File($data['data']);
86
    }
87
88
}