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.

ImportBatch::buildRequestParams()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 0
cts 12
cp 0
rs 9.6333
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 6
1
<?php
2
3
namespace Vindi;
4
5
/**
6
 * Class ImportBatch
7
 *
8
 * @package Vindi
9
 */
10
class ImportBatch extends Resource
11
{
12
    /**
13
     * The endpoint that will hit the API.
14
     *
15
     * @return string
16
     */
17 16
    public function endPoint()
18
    {
19 16
        return 'import_batches';
20
    }
21
22
    /**
23
     * @param string $filePath
24
     * @param array  $options
25
     *
26
     * @return mixed
27
     * @throws \GuzzleHttp\Exception\GuzzleException
28
     * @throws \Vindi\Exceptions\RateLimitException
29
     * @throws \Vindi\Exceptions\RequestException
30
     */
31
    public function import($filePath, array $options)
32
    {
33
        $file = new \SplFileObject($filePath);
34
        $requestParams = $this->buildRequestParams($file, $options);
35
36
        return $this->apiRequester->request('POST', $this->url(), $requestParams);
37
    }
38
39
    /**
40
     * @param \SplFileObject $file
41
     * @param array $options
42
     *
43
     * @return array
44
     */
45
    private function buildRequestParams(\SplFileObject $file, array $options)
46
    {
47
        $multipart = [
48
            [
49
                'name' =>'batch',
50
                'contents' => $file,
51
                'filename' => $file->getFilename()
52
            ]
53
        ];
54
55
        foreach ($options as $key => $value) {
56
            $multipart[] = [
57
                'name'      => $key,
58
                'contents'  => $value
59
            ];
60
        }
61
62
        return compact('multipart');
63
    }
64
}
65