AbstractLocation   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 17
dl 0
loc 38
ccs 0
cts 14
cp 0
rs 10
c 2
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A _getRawResponse() 0 22 2
1
<?php
2
3
namespace LE_ACME2\Request\Account;
4
5
use LE_ACME2\Request\AbstractRequest;
6
7
use LE_ACME2\Connector;
8
use LE_ACME2\Cache;
9
use LE_ACME2\Utilities;
10
use LE_ACME2\Exception;
11
12
use LE_ACME2\Account;
13
14
abstract class AbstractLocation extends AbstractRequest {
15
16
    protected $_account;
17
18
    public function __construct(Account $account) {
19
        $this->_account = $account;
20
    }
21
22
    /**
23
     * @throws Exception\InvalidResponse
24
     * @throws Exception\RateLimitReached
25
     * @throws Exception\ServiceUnavailable
26
     */
27
    protected function _getRawResponse() : Connector\RawResponse {
28
29
        $payload = $this->_getPayload();
30
        if(count($payload) == 0) {
31
            $payload['rand-' . rand(100000, 1000000)] = 1;
32
        }
33
34
        $kid = Utilities\RequestSigner::KID(
35
            $payload,
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
            Cache\AccountResponse::getInstance()->get($this->_account)->getLocation(),
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
            Cache\AccountResponse::getInstance()->get($this->_account)->getLocation(),
45
            $kid
46
        );
47
48
        return $result;
49
    }
50
51
    abstract protected function _getPayload() : array;
52
}