Get::getResponse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 17
ccs 0
cts 9
cp 0
rs 9.9
c 1
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace LE_ACME2\Request\Authorization;
4
5
use LE_ACME2\Request\AbstractRequest;
6
7
use LE_ACME2\Connector;
8
use LE_ACME2\Cache;
9
use LE_ACME2\Exception;
10
use LE_ACME2\Response;
11
use LE_ACME2\Utilities;
12
13
use LE_ACME2\Account;
14
15
class Get extends AbstractRequest {
16
17
    protected $_account;
18
    protected $_authorizationURL;
19
20
    public function __construct(Account $account, string $authorizationURL) {
21
22
        $this->_account = $account;
23
        $this->_authorizationURL = $authorizationURL;
24
    }
25
26
    /**
27
     * @throws Exception\InvalidResponse
28
     * @throws Exception\RateLimitReached
29
     * @throws Exception\ExpiredAuthorization
30
     * @throws Exception\ServiceUnavailable
31
     */
32
    public function getResponse() : Response\Authorization\Get {
33
34
        $kid = Utilities\RequestSigner::KID(
35
            null,
36
            Cache\AccountResponse::getInstance()->get($this->_account)->getLocation(),
0 ignored issues
show
Bug introduced by
It seems like get() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
            Cache\AccountResponse::getInstance()->/** @scrutinizer ignore-call */ get($this->_account)->getLocation(),
Loading history...
37
            $this->_authorizationURL,
38
            Cache\NewNonceResponse::getInstance()->get()->getNonce(),
39
            $this->_account->getKeyDirectoryPath()
40
        );
41
42
        $result = Connector\Connector::getInstance()->request(
0 ignored issues
show
Bug introduced by
It seems like request() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

42
        $result = Connector\Connector::getInstance()->/** @scrutinizer ignore-call */ request(
Loading history...
43
            Connector\Connector::METHOD_POST,
44
            $this->_authorizationURL,
45
            $kid
46
        );
47
48
        return new Response\Authorization\Get($result);
49
    }
50
}