Start   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 21
dl 0
loc 42
ccs 0
cts 15
cp 0
rs 10
c 2
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getResponse() 0 23 1
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\Struct\ChallengeAuthorizationKey;
12
use LE_ACME2\Utilities;
13
14
use LE_ACME2\Account;
15
use LE_ACME2\Order;
16
17
class Start extends AbstractRequest {
18
19
    protected $_account;
20
    protected $_order;
21
    protected $_challenge;
22
23
    public function __construct(Account $account, Order $order, Response\Authorization\Struct\Challenge $challenge) {
24
25
        $this->_account = $account;
26
        $this->_order = $order;
27
        $this->_challenge = $challenge;
28
    }
29
30
    /**
31
     * @throws Exception\InvalidResponse
32
     * @throws Exception\RateLimitReached
33
     * @throws Exception\ExpiredAuthorization
34
     * @throws Exception\ServiceUnavailable
35
     */
36
    public function getResponse() : Response\Authorization\Start {
37
38
        Cache\OrderAuthorizationResponse::getInstance()->clear($this->_order);
0 ignored issues
show
Bug introduced by
It seems like clear() 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

38
        Cache\OrderAuthorizationResponse::getInstance()->/** @scrutinizer ignore-call */ clear($this->_order);
Loading history...
39
40
        $payload = [
41
            'keyAuthorization' => (new ChallengeAuthorizationKey($this->_account))->get($this->_challenge->token)
42
        ];
43
44
        $kid = Utilities\RequestSigner::KID(
45
            $payload,
46
            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

46
            Cache\AccountResponse::getInstance()->/** @scrutinizer ignore-call */ get($this->_account)->getLocation(),
Loading history...
47
            $this->_challenge->url,
48
            Cache\NewNonceResponse::getInstance()->get()->getNonce(),
49
            $this->_account->getKeyDirectoryPath()
50
        );
51
52
        $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

52
        $result = Connector\Connector::getInstance()->/** @scrutinizer ignore-call */ request(
Loading history...
53
            Connector\Connector::METHOD_POST,
54
            $this->_challenge->url,
55
            $kid
56
        );
57
58
        return new Response\Authorization\Start($result);
59
    }
60
}