This commit is contained in:
Mathieu 2024-01-11 12:42:03 +00:00
parent c7cd2fbbca
commit 4b11b32cbc
2 changed files with 5 additions and 3 deletions

View File

@ -7,9 +7,9 @@ class MultiDownloaderClient
private string $apiUrl = 'https://multi-dl.kub.nwb.fr';
private string $apiKey;
public function __construct(string $apiKey = null)
public function __construct(array $options = [])
{
$apiKey = $apiKey ?? getenv('MULTI_DOWNLOADER_API_KEY');
$apiKey = $options['apiKey'] ?? getenv('MULTI_DOWNLOADER_API_KEY');
if (!$apiKey) {
throw new \InvalidArgumentException('API key is required');

View File

@ -63,7 +63,9 @@ class MultiDownloaderClientTest extends TestCase
public function testApiKeyParam()
{
$client = new MultiDownloaderClient('test_key');
$client = new MultiDownloaderClient([
'apiKey' => 'test_key'
]);
$apiKey = self::getProperty($client, 'apiKey');
$this->assertEquals('test_key', $apiKey);