Status   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 63
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getServerTime() 0 11 1
A getServerStatus() 0 15 1
1
<?php
2
3
namespace Sausin\Signere;
4
5
use GuzzleHttp\Client;
6
use Illuminate\Contracts\Config\Repository as Config;
7
8
class Status extends BaseClass
9
{
10
    /** @var \Illuminate\Contracts\Config\Repository */
11
    protected $config;
12
13
    /** The URI of the action */
14
    const URI = 'https://api.signere.no/api/Status';
15
16
    /**
17
     * Instantiate the class.
18
     *
19
     * @param Client  $client
20
     * @param Headers $headers
21
     * @param Config  $config
22
     * @param string  $environment
23
     */
24 3
    public function __construct(Client $client, Headers $headers, Config $config, $environment = null)
25
    {
26 3
        $this->client = $client;
27 3
        $this->headers = $headers;
28 3
        $this->config = $config;
29 3
        $this->environment = $environment;
30 3
    }
31
32
    /**
33
     * Returns the UTC time of the server.
34
     *
35
     * @return object
36
     */
37 1
    public function getServerTime()
38
    {
39
        // make the URL for this request
40 1
        $url = sprintf('%s/ServerTime', $this->getBaseUrl());
41
42
        // get the response
43 1
        $response = $this->client->get($url);
44
45
        // return the response
46 1
        return $response;
47
    }
48
49
    /**
50
     * Returns the status the server.
51
     *
52
     * @param  string $request
53
     * @return object
54
     */
55 1
    public function getServerStatus(string $request = 'test')
56
    {
57
        // make the URL for this request
58 1
        $url = sprintf('%s/Ping/%s', $this->getBaseUrl(), $request);
59
60
        // get the response
61 1
        $response = $this->client->get($url, [
62 1
            'headers' => array_merge(
63 1
                ['PingToken' => $this->config->get('signere.ping_token')]
64
            ),
65
        ]);
66
67
        // return the response
68 1
        return $response;
69
    }
70
}
71