Get::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 2
crap 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 Get extends AbstractRequest {
16
17
    protected Order $_order;
18
    private string $location;
19
20
    public function __construct(Order $order, string $location) {
21
22
        $this->_order = $order;
23
        $this->location = $location;
24
    }
25
26
    /**
27
     * @throws Exception\InvalidResponse
28
     * @throws Exception\RateLimitReached
29
     * @throws Exception\ServiceUnavailable
30
     */
31
    public function getResponse() : Response\Order\Get {
32
33
        $kid = Utilities\RequestSigner::KID(
34
            null,
35
            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

35
            Cache\AccountResponse::getInstance()->/** @scrutinizer ignore-call */ get($this->_order->getAccount())->getLocation(),
Loading history...
36
            $this->location,
37
            Cache\NewNonceResponse::getInstance()->get()->getNonce(),
38
            $this->_order->getAccount()->getKeyDirectoryPath()
39
        );
40
41
        $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

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