Passed
Push — master ( 55c384...001f9d )
by Tim
09:13 queued 07:21
created

Mono::coverage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Digikraaft\Mono;
4
5
use Digikraaft\Mono\Exceptions\InvalidArgumentException;
6
7
class Mono extends ApiResource
8
{
9
    /** @var string The Mono API key to be used for requests. */
10
    public static string $secretKey;
11
12
    /** @var string The base URL for the Mono API. */
13
    public static $apiBaseUrl = 'https://api.withmono.com';
14
15
    /**
16
     * @return string the API key used for requests
17
     */
18
    public static function getSecretKey(): string
19
    {
20
        return self::$secretKey;
21
    }
22
23
    /**
24
     * Sets the API key to be used for requests.
25
     *
26
     * @param string $secretKey
27
     */
28
    public static function setSecretKey($secretKey): void
29
    {
30
        self::validateSecretKey($secretKey);
31
        self::$secretKey = $secretKey;
32
    }
33
34
    private static function validateSecretKey($secretKey): bool
35
    {
36
        if ($secretKey == '' || ! is_string($secretKey)) {
37
            throw new InvalidArgumentException('Secret key must be a string and cannot be empty');
38
        }
39
40
        return true;
41
    }
42
43
    /**
44
     * @return array|object
45
     * @throws Exceptions\IsNullException
46
     * @throws InvalidArgumentException
47
     * @link https://docs.mono.co/reference#list-institutions
48
     */
49
    public static function coverage()
50
    {
51
        $url = "coverage";
52
53
        return static::staticRequest('GET', $url);
54
    }
55
}
56