Mono::coverage()   A
last analyzed

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()
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)
29
    {
30
        self::validateSecretKey($secretKey);
31
        self::$secretKey = $secretKey;
32
    }
33
34
    /**
35
     * @param $secretKey
36
     * @return bool
37
     * @throws InvalidArgumentException
38
     */
39
    private static function validateSecretKey($secretKey)
40
    {
41
        if ($secretKey == '' || ! is_string($secretKey)) {
42
            throw new InvalidArgumentException('Secret key must be a string and cannot be empty');
43
        }
44
45
        return true;
46
    }
47
48
    /**
49
     * @return array|object
50
     * @throws Exceptions\IsNullException
51
     * @throws InvalidArgumentException
52
     * @link https://docs.mono.co/reference#list-institutions
53
     */
54
    public static function coverage()
55
    {
56
        $url = "coverage";
57
58
        return static::staticRequest('GET', $url);
59
    }
60
}
61