1 | <?php |
||
2 | |||
3 | namespace Digikraaft\Flutterwave; |
||
4 | |||
5 | use Digikraaft\Flutterwave\Exceptions\InvalidArgumentException; |
||
6 | |||
7 | class Flutterwave |
||
8 | { |
||
9 | /** @var string The Flutterwave API key to be used for requests. */ |
||
10 | public static string $apiKey; |
||
11 | |||
12 | /** @var string The instance API key, settable once per new instance */ |
||
13 | private $instanceApiKey; |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
14 | |||
15 | /** @var string The base URL for the Flutterwave API. */ |
||
16 | public static $apiBase = 'https://api.flutterwave.com/v3'; |
||
17 | |||
18 | /** |
||
19 | * @return string the API key used for requests |
||
20 | */ |
||
21 | public static function getApiKey(): string |
||
22 | { |
||
23 | return self::$apiKey; |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * Sets the API key to be used for requests. |
||
28 | * |
||
29 | * @param string $apiKey |
||
30 | */ |
||
31 | public static function setApiKey($apiKey): void |
||
32 | { |
||
33 | self::validateApiKey($apiKey); |
||
34 | self::$apiKey = $apiKey; |
||
35 | } |
||
36 | |||
37 | private static function validateApiKey($apiKey): bool |
||
38 | { |
||
39 | if ($apiKey == '' || ! is_string($apiKey)) { |
||
40 | throw new InvalidArgumentException('Api key must be a string and cannot be empty'); |
||
41 | } |
||
42 | |||
43 | return true; |
||
44 | } |
||
45 | } |
||
46 |