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.

ProposalsClient::store()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 11
c 1
b 0
f 0
nc 1
nop 6
dl 0
loc 22
ccs 11
cts 11
cp 1
crap 1
rs 9.9
1
<?php
2
3
namespace NStack\Clients;
4
5
use NStack\Exceptions\FailedToParseException;
6
use NStack\Models\Proposal;
7
use NStack\Models\ProposalDeleted;
0 ignored issues
show
Bug introduced by
The type NStack\Models\ProposalDeleted was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
/**
10
 * Class ProposalsClient
11
 *
12
 * @package NStack\Clients
13
 * @author  Tiago Araujo <[email protected]>
14
 */
15
class ProposalsClient extends NStackClient
16
{
17
    /** @var string */
18
    protected $path = 'localize/proposals';
19
20
    /**
21
     * index
22
     *
23
     * @param String|null $guid
24
     * @return array
25
     * @throws FailedToParseException
26
     */
27 1
    public function index(String $guid = null): array
28
    {
29 1
        $response = $this->client->get($this->buildPath($this->path . '?guid=' . $guid));
30 1
        $contents = $response->getBody()->getContents();
31 1
        $data = json_decode($contents, true);
32
33 1
        $array = [];
34 1
        foreach ($data['data'] as $object) {
35 1
            $array[] = new Proposal($object);
36
        }
37
38 1
        return $array;
39
    }
40
41
    /**
42
     * store
43
     *
44
     * @param String|null $guid
45
     * @param String      $key
46
     * @param String      $value
47
     * @param String      $platform
48
     * @param String      $locale
49
     * @param String      $section
50
     * @return Proposal
51
     * @throws FailedToParseException
52
     */
53 1
    public function store(
54
        String $guid,
55
        String $key,
56
        String $value,
57
        String $platform,
58
        String $locale,
59
        String $section
60
    ) {
61 1
        $response = $this->client->post($this->buildPath($this->path), [
62
            'form_params' => [
63 1
                'key'      => $key,
64 1
                'value'    => $value,
65 1
                'locale'   => $locale,
66 1
                'platform' => $platform,
67 1
                'guid'     => $guid,
68 1
                'section'  => $section,
69
            ],
70
        ]);
71 1
        $contents = $response->getBody()->getContents();
72 1
        $data = json_decode($contents, true);
73
74 1
        return new Proposal($data['data']);
75
    }
76
77
    /**
78
     * delete
79
     *
80
     * @param int    $id
81
     * @param String $guid
82
     */
83
    public function delete(int $id, String $guid)
84
    {
85
        $this->client->delete($this->buildPath($this->path . '/' . $id . '?guid=' . $guid));
86
    }
87
}