Mono   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
eloc 11
c 2
b 0
f 0
dl 0
loc 52
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setSecretKey() 0 4 1
A getSecretKey() 0 3 1
A validateSecretKey() 0 7 3
A coverage() 0 5 1
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