|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace LE_ACME2\Response\Order; |
|
4
|
|
|
|
|
5
|
|
|
use LE_ACME2\Response\AbstractResponse; |
|
6
|
|
|
use LE_ACME2\Exception; |
|
7
|
|
|
use LE_ACME2\Response\Order\Struct\OrderError; |
|
8
|
|
|
|
|
9
|
|
|
abstract class AbstractOrder extends AbstractResponse { |
|
10
|
|
|
|
|
11
|
|
|
const STATUS_PENDING = 'pending'; |
|
12
|
|
|
const STATUS_VALID = 'valid'; |
|
13
|
|
|
const STATUS_READY = 'ready'; |
|
14
|
|
|
const STATUS_INVALID = 'invalid'; |
|
15
|
|
|
|
|
16
|
|
|
public function getLocation() : string { |
|
17
|
|
|
|
|
18
|
|
|
$matches = $this->_preg_match_headerLine($this->_pattern_header_location); |
|
|
|
|
|
|
19
|
|
|
return trim($matches[1]); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
public function getStatus() : string { |
|
23
|
|
|
return $this->_raw->body['status']; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function getExpires() : string { |
|
27
|
|
|
return $this->_raw->body['expires']; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function getIdentifiers() : array { |
|
31
|
|
|
return $this->_raw->body['identifiers']; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @return array<string> Authorization urls |
|
36
|
|
|
*/ |
|
37
|
|
|
public function getAuthorizations() : array { |
|
38
|
|
|
return $this->_raw->body['authorizations']; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function getFinalize() : string { |
|
42
|
|
|
return $this->_raw->body['finalize']; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function getCertificate() : string { |
|
46
|
|
|
return $this->_raw->body['certificate']; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @throws Exception\OrderStatusInvalid |
|
51
|
|
|
*/ |
|
52
|
|
|
protected function _isValid(): bool { |
|
53
|
|
|
|
|
54
|
|
|
if(!parent::_isValid()) { |
|
55
|
|
|
return false; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
if( |
|
59
|
|
|
$this->getStatus() == AbstractOrder::STATUS_INVALID |
|
60
|
|
|
) { |
|
61
|
|
|
throw new Exception\OrderStatusInvalid( |
|
62
|
|
|
'. Probably all authorizations have failed. ' . PHP_EOL . |
|
63
|
|
|
'Please see: ' . $this->getLocation() . PHP_EOL . |
|
64
|
|
|
'Continue by using $order->clear() after getting rid of the problem', |
|
65
|
|
|
$this, |
|
66
|
|
|
); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
return true; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function getError() : ?Struct\OrderError { |
|
73
|
|
|
|
|
74
|
|
|
if( |
|
75
|
|
|
!isset($this->_raw->body['error']) |
|
76
|
|
|
|| !is_array($this->_raw->body['error']) |
|
77
|
|
|
) { |
|
78
|
|
|
return null; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
return OrderError::createFrom($this->_raw->body['error']); |
|
82
|
|
|
} |
|
83
|
|
|
} |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.