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.
Completed
Push — master ( c032ab...c5117f )
by Erico
02:37
created

ImportBatch   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 11.11%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A buildRequestParams() 0 19 2
A endPoint() 0 4 1
A import() 0 7 1
1
<?php
2
3
namespace Vindi;
4
5
class ImportBatch extends Resource
6
{
7
    /**
8
     * The endpoint that will hit the API.
9
     *
10
     * @return string
11
     */
12 16
    public function endPoint()
13
    {
14 16
        return 'import_batches';
15
    }
16
17
    /**
18
     * @param string $filePath
19
     * @param array $options
20
     *
21
     * @return mixed
22
     */
23
    public function import($filePath, array $options)
24
    {
25
        $file = new \SplFileObject($filePath);
26
        $requestParams = $this->buildRequestParams($file, $options);
27
28
        return $this->apiRequester->request('POST', $this->url(), $requestParams);
29
    }
30
31
    /**
32
     * @param \SplFileObject $file
33
     * @param array $options
34
     *
35
     * @return array
36
     */
37
    private function buildRequestParams(\SplFileObject $file, array $options)
38
    {
39
        $multipart = [
40
            [
41
                'name' =>'batch',
42
                'contents' => $file,
43
                'filename' => $file->getFilename()
44
            ]
45
        ];
46
47
        foreach ($options as $key => $value) {
48
            $multipart[] = [
49
                'name'      => $key,
50
                'contents'  => $value
51
            ];
52
        }
53
54
        return compact('multipart');
55
    }
56
}
57