Create   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 23
dl 0
loc 45
ccs 0
cts 14
cp 0
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getResponse() 0 31 2
1
<?php
2
3
namespace LE_ACME2\Request\Order;
4
5
use LE_ACME2\Request\AbstractRequest;
6
use LE_ACME2\Response;
7
8
use LE_ACME2\Connector;
9
use LE_ACME2\Cache;
10
use LE_ACME2\Exception;
11
use LE_ACME2\Utilities;
12
13
use LE_ACME2\Order;
14
15
class Create extends AbstractRequest {
16
17
    protected $_order;
18
19
    public function __construct(Order $order) {
20
21
        $this->_order = $order;
22
    }
23
24
    /**
25
     * @throws Exception\InvalidResponse
26
     * @throws Exception\RateLimitReached
27
     * @throws Exception\ServiceUnavailable
28
     */
29
    public function getResponse() : Response\Order\Create {
30
31
        $identifiers = [];
32
        foreach($this->_order->getSubjects() as $subject) {
33
34
            $identifiers[] = [
35
                'type' => 'dns',
36
                'value' => $subject
37
            ];
38
        }
39
40
        $payload = [
41
            'identifiers' => $identifiers,
42
            'notBefore' => '',
43
            'notAfter' => '',
44
        ];
45
46
        $kid = Utilities\RequestSigner::KID(
47
            $payload,
48
            Cache\AccountResponse::getInstance()->get($this->_order->getAccount())->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

48
            Cache\AccountResponse::getInstance()->/** @scrutinizer ignore-call */ get($this->_order->getAccount())->getLocation(),
Loading history...
49
            Cache\DirectoryResponse::getInstance()->get()->getNewOrder(),
50
            Cache\NewNonceResponse::getInstance()->get()->getNonce(),
51
            $this->_order->getAccount()->getKeyDirectoryPath()
52
        );
53
        $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

53
        $result = Connector\Connector::getInstance()->/** @scrutinizer ignore-call */ request(
Loading history...
54
            Connector\Connector::METHOD_POST,
55
            Cache\DirectoryResponse::getInstance()->get()->getNewOrder(),
56
            $kid
57
        );
58
59
        return new Response\Order\Create($result);
60
    }
61
}