Directory::newAccount()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Rogierw\RwAcme\Endpoints;
4
5
use Rogierw\RwAcme\Exceptions\LetsEncryptClientException;
6
use Rogierw\RwAcme\Http\Response;
7
8
class Directory extends Endpoint
9
{
10
    public function all(): Response
11
    {
12
        $response = $this->client
13
            ->getHttpClient()
14
            ->get($this->client->getBaseUrl() . '/directory');
15
16
        if ($response->getHttpResponseCode() >= 400) {
17
            $this->logResponse('error', 'Cannot get directory', $response);
18
19
            throw new LetsEncryptClientException('Cannot get directory');
20
        }
21
22
        return $response;
23
    }
24
25
    public function newNonce(): string
26
    {
27
        return $this->all()->getBody()['newNonce'];
28
    }
29
30
    public function newAccount(): string
31
    {
32
        return $this->all()->getBody()['newAccount'];
33
    }
34
35
    public function newOrder(): string
36
    {
37
        return $this->all()->getBody()['newOrder'];
38
    }
39
40
    public function getOrder(): string
41
    {
42
        $url = str_replace('new-order', 'order', $this->newOrder());
43
44
        return rtrim($url, '/') . '/';
45
    }
46
47
    public function revoke(): string
48
    {
49
        return $this->all()->getBody()['revokeCert'];
50
    }
51
}
52