Api   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 8
c 2
b 0
f 0
dl 0
loc 21
ccs 0
cts 10
cp 0
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A uploadFile() 0 11 1
1
<?php
2
3
namespace Distilleries\Contentful\Api\Upload;
4
5
use GuzzleHttp\RequestOptions;
6
use Distilleries\Contentful\Api\BaseApi;
7
use Distilleries\Contentful\Api\UploadApi;
8
9
class Api extends BaseApi implements UploadApi
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    protected $baseUrl = 'https://upload.contentful.com';
15
16
    /**
17
     * {@inheritdoc}
18
     */
19
    public function uploadFile(string $file): array
20
    {
21
        $response = $this->client->request('POST', $this->url('uploads'), [
22
            RequestOptions::BODY => file_get_contents($file),
23
            RequestOptions::HEADERS => [
24
                'Content-Type' => 'application/octet-stream',
25
                'Authorization' => 'Bearer ' . $this->config['tokens']['management'],
26
            ],
27
        ]);
28
29
        return $this->decodeResponse($response);
30
    }
31
}
32