From 4b11b32cbc06139f32927f07747a6b6dba0ca72b Mon Sep 17 00:00:00 2001 From: Mathieu Date: Thu, 11 Jan 2024 12:42:03 +0000 Subject: [PATCH] options --- src/MultiDownloaderClient.php | 4 ++-- tests/MultiDownloaderClientTest.php | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/MultiDownloaderClient.php b/src/MultiDownloaderClient.php index 3401bf4..e6807d9 100644 --- a/src/MultiDownloaderClient.php +++ b/src/MultiDownloaderClient.php @@ -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'); diff --git a/tests/MultiDownloaderClientTest.php b/tests/MultiDownloaderClientTest.php index 8470136..594b08d 100644 --- a/tests/MultiDownloaderClientTest.php +++ b/tests/MultiDownloaderClientTest.php @@ -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);