Issues (1)

src/Endpoints/Download.php (1 issue)

Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace OpenSubtitles\Endpoints;
6
7
use GuzzleHttp\ClientInterface;
8
use GuzzleHttp\Exception\GuzzleException;
9
use GuzzleHttp\RequestOptions;
10
use OpenSubtitles\HttpClientHandler;
11
12
class Download implements Endpoint
13
{
14
    private string $baseUrl;
15
16
    /**
17
     * @var HttpClientHandler
18
     */
19
    private HttpClientHandler $clientHandler;
20
21
    public function __construct(ClientInterface $client, string $baseUrl, string $apiKey = null)
22
    {
23
        $this->baseUrl = $baseUrl;
24
25
        $this->clientHandler = new HttpClientHandler($client);
26
        if ($apiKey) {
27
            $this->clientHandler->setApiKey($apiKey);
28
        }
29
    }
30
31
    /**
32
     * Request a download url for a subtitle.
33
     *
34
     * @param string $accessToken
35
     * @param int $fileId
36
     * @param array $params
37
     * @return mixed
38
     * @throws GuzzleException
39
     */
40
    public function download(string $accessToken, int $fileId, array $params = [])
0 ignored issues
show
The parameter $params is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

40
    public function download(string $accessToken, int $fileId, /** @scrutinizer ignore-unused */ array $params = [])

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
41
    {
42
        return $this->clientHandler->toJson(
43
            $this->clientHandler->setAccessToken($accessToken)->post(
44
                $this->baseUrl . '/download',
45
                [
46
                    RequestOptions::HEADERS => [
47
                        // If the accept header dont set, this won't run (response: 406 Not Acceptable)
48
                        'Accept' => 'application/json',
49
                        'Content-Type' => 'multipart/form-data',
50
                    ],
51
                    RequestOptions::FORM_PARAMS => ['file_id' => $fileId],
52
                ]
53
            )
54
        );
55
    }
56
}
57