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   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 11.11%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 55
ccs 2
cts 18
cp 0.1111
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A endPoint() 0 4 1
A import() 0 7 1
A buildRequestParams() 0 19 2
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