@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | public static function setCommonKeyDirectoryPath(string $directoryPath) { |
17 | 17 | |
18 | - if(!file_exists($directoryPath)) { |
|
18 | + if (!file_exists($directoryPath)) { |
|
19 | 19 | throw new \RuntimeException('Common Key Directory Path does not exist'); |
20 | 20 | } |
21 | 21 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | protected function _getKeyDirectoryPath(string $appendix = '') : string { |
30 | 30 | |
31 | - if(self::$_directoryPath === null) { |
|
31 | + if (self::$_directoryPath === null) { |
|
32 | 32 | throw new \RuntimeException('Common Key Directory Path is not set'); |
33 | 33 | } |
34 | 34 | |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | |
43 | 43 | protected function _initKeyDirectory(string $keyType = self::KEY_TYPE_RSA, bool $ignoreIfKeysExist = false) { |
44 | 44 | |
45 | - if(!file_exists($this->getKeyDirectoryPath())) { |
|
45 | + if (!file_exists($this->getKeyDirectoryPath())) { |
|
46 | 46 | |
47 | 47 | mkdir($this->getKeyDirectoryPath()); |
48 | 48 | } |
49 | 49 | |
50 | - if(!$ignoreIfKeysExist && ( |
|
50 | + if (!$ignoreIfKeysExist && ( |
|
51 | 51 | file_exists($this->getKeyDirectoryPath() . 'private.pem') || |
52 | 52 | file_exists($this->getKeyDirectoryPath() . 'public.pem') |
53 | 53 | ) |
@@ -59,14 +59,14 @@ discard block |
||
59 | 59 | ); |
60 | 60 | } |
61 | 61 | |
62 | - if($keyType == self::KEY_TYPE_RSA) { |
|
62 | + if ($keyType == self::KEY_TYPE_RSA) { |
|
63 | 63 | |
64 | 64 | Utilities\KeyGenerator::RSA( |
65 | 65 | $this->getKeyDirectoryPath(), |
66 | 66 | 'private.pem', |
67 | 67 | 'public.pem' |
68 | 68 | ); |
69 | - } else if($keyType == self::KEY_TYPE_EC) { |
|
69 | + } else if ($keyType == self::KEY_TYPE_EC) { |
|
70 | 70 | |
71 | 71 | Utilities\KeyGenerator::EC( |
72 | 72 | $this->getKeyDirectoryPath(), |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | |
82 | 82 | protected function _clearKeyDirectory() { |
83 | 83 | |
84 | - if(file_exists($this->getKeyDirectoryPath() . 'private.pem')) { |
|
84 | + if (file_exists($this->getKeyDirectoryPath() . 'private.pem')) { |
|
85 | 85 | unlink($this->getKeyDirectoryPath() . 'private.pem'); |
86 | 86 | } |
87 | 87 | |
88 | - if(file_exists($this->getKeyDirectoryPath() . 'public.pem')) { |
|
88 | + if (file_exists($this->getKeyDirectoryPath() . 'public.pem')) { |
|
89 | 89 | unlink($this->getKeyDirectoryPath() . 'public.pem'); |
90 | 90 | } |
91 | 91 | } |
@@ -7,7 +7,7 @@ |
||
7 | 7 | public function __construct(string $function) { |
8 | 8 | |
9 | 9 | $errors = []; |
10 | - while(($error = openssl_error_string()) !== false) { |
|
10 | + while (($error = openssl_error_string()) !== false) { |
|
11 | 11 | $errors[] = $error; |
12 | 12 | } |
13 | 13 |
@@ -18,15 +18,15 @@ discard block |
||
18 | 18 | $this->_rawResponse = $rawResponse; |
19 | 19 | $this->_responseStatus = $responseStatus; |
20 | 20 | |
21 | - if($responseStatus === '') { |
|
21 | + if ($responseStatus === '') { |
|
22 | 22 | $responseStatus = 'Unknown response status'; |
23 | 23 | } |
24 | 24 | |
25 | - if(isset($this->_rawResponse->body['type'])) { |
|
25 | + if (isset($this->_rawResponse->body['type'])) { |
|
26 | 26 | $responseStatus = $this->_responseStatusType = $this->_rawResponse->body['type']; |
27 | 27 | } |
28 | 28 | |
29 | - if(isset($this->_rawResponse->body['detail'])) { |
|
29 | + if (isset($this->_rawResponse->body['detail'])) { |
|
30 | 30 | $responseStatus .= ' - ' . $this->_rawResponse->body['detail']; |
31 | 31 | } |
32 | 32 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | public function getResponseStatusDetail() : ?string { |
49 | 49 | |
50 | - if(isset($this->_rawResponse->body['detail'])) { |
|
50 | + if (isset($this->_rawResponse->body['detail'])) { |
|
51 | 51 | return $this->_rawResponse->body['detail']; |
52 | 52 | } |
53 | 53 | return null; |
@@ -27,7 +27,7 @@ |
||
27 | 27 | protected function _getRawResponse() : Connector\RawResponse { |
28 | 28 | |
29 | 29 | $payload = $this->_getPayload(); |
30 | - if(count($payload) == 0) { |
|
30 | + if (count($payload) == 0) { |
|
31 | 31 | $payload['rand-' . rand(100000, 1000000)] = 1; |
32 | 32 | } |
33 | 33 |
@@ -20,7 +20,7 @@ |
||
20 | 20 | |
21 | 21 | $result = $connector->request( |
22 | 22 | Connector::METHOD_GET, |
23 | - $connector->getBaseURL() . '/directory' |
|
23 | + $connector->getBaseURL() . '/directory' |
|
24 | 24 | ); |
25 | 25 | return new Response\GetDirectory($result); |
26 | 26 | } |
@@ -33,7 +33,7 @@ |
||
33 | 33 | |
34 | 34 | $csr = Utilities\Certificate::generateCSR($this->_order); |
35 | 35 | |
36 | - if(preg_match('~-----BEGIN\sCERTIFICATE\sREQUEST-----(.*)-----END\sCERTIFICATE\sREQUEST-----~s', $csr, $matches)) |
|
36 | + if (preg_match('~-----BEGIN\sCERTIFICATE\sREQUEST-----(.*)-----END\sCERTIFICATE\sREQUEST-----~s', $csr, $matches)) |
|
37 | 37 | $csr = $matches[1]; |
38 | 38 | |
39 | 39 | $csr = trim(Utilities\Base64::UrlSafeEncode(base64_decode($csr))); |
@@ -33,8 +33,9 @@ |
||
33 | 33 | |
34 | 34 | $csr = Utilities\Certificate::generateCSR($this->_order); |
35 | 35 | |
36 | - if(preg_match('~-----BEGIN\sCERTIFICATE\sREQUEST-----(.*)-----END\sCERTIFICATE\sREQUEST-----~s', $csr, $matches)) |
|
37 | - $csr = $matches[1]; |
|
36 | + if(preg_match('~-----BEGIN\sCERTIFICATE\sREQUEST-----(.*)-----END\sCERTIFICATE\sREQUEST-----~s', $csr, $matches)) { |
|
37 | + $csr = $matches[1]; |
|
38 | + } |
|
38 | 39 | |
39 | 40 | $csr = trim(Utilities\Base64::UrlSafeEncode(base64_decode($csr))); |
40 | 41 |
@@ -29,7 +29,7 @@ |
||
29 | 29 | public function getResponse() : Response\AbstractResponse { |
30 | 30 | |
31 | 31 | $identifiers = []; |
32 | - foreach($this->_order->getSubjects() as $subject) { |
|
32 | + foreach ($this->_order->getSubjects() as $subject) { |
|
33 | 33 | |
34 | 34 | $identifiers[] = [ |
35 | 35 | 'type' => 'dns', |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | $this->_order = $order; |
25 | 25 | $this->_orderResponse = $orderResponse; |
26 | 26 | |
27 | - if($alternativeUrl !== null) { |
|
27 | + if ($alternativeUrl !== null) { |
|
28 | 28 | $this->_alternativeUrl = $alternativeUrl; |
29 | 29 | } |
30 | 30 | } |
@@ -37,8 +37,7 @@ discard block |
||
37 | 37 | public function getResponse() : Response\AbstractResponse { |
38 | 38 | |
39 | 39 | $url = $this->_alternativeUrl === null ? |
40 | - $this->_orderResponse->getCertificate() : |
|
41 | - $this->_alternativeUrl; |
|
40 | + $this->_orderResponse->getCertificate() : $this->_alternativeUrl; |
|
42 | 41 | |
43 | 42 | $kid = Utilities\RequestSigner::KID( |
44 | 43 | null, |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | Utilities\Logger::getInstance()->add( |
45 | 45 | Utilities\Logger::LEVEL_INFO, |
46 | - get_class() . '::' . __FUNCTION__ . ' email: "' . $email . '"' |
|
46 | + get_class() . '::' . __FUNCTION__ . ' email: "' . $email . '"' |
|
47 | 47 | ); |
48 | 48 | |
49 | 49 | $account = new self($email); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | return $account; |
60 | 60 | |
61 | - } catch(Exception\AbstractException $e) { |
|
61 | + } catch (Exception\AbstractException $e) { |
|
62 | 62 | |
63 | 63 | $account->_clearKeyDirectory(); |
64 | 64 | throw $e; |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | |
79 | 79 | Utilities\Logger::getInstance()->add( |
80 | 80 | Utilities\Logger::LEVEL_INFO, |
81 | - get_class() . '::' . __FUNCTION__ . ' email: "' . $email . '"' |
|
81 | + get_class() . '::' . __FUNCTION__ . ' email: "' . $email . '"' |
|
82 | 82 | ); |
83 | 83 | |
84 | 84 | $account = new self($email); |
85 | 85 | |
86 | - if(!self::exists($email)) |
|
86 | + if (!self::exists($email)) |
|
87 | 87 | throw new \RuntimeException('Keys not found - does this account exist?'); |
88 | 88 | |
89 | 89 | return $account; |
@@ -116,12 +116,12 @@ discard block |
||
116 | 116 | |
117 | 117 | $this->_setEmail($email); |
118 | 118 | |
119 | - if($previousKeyDirectoryPath != $this->getKeyDirectoryPath()) |
|
119 | + if ($previousKeyDirectoryPath != $this->getKeyDirectoryPath()) |
|
120 | 120 | rename($previousKeyDirectoryPath, $this->getKeyDirectoryPath()); |
121 | 121 | |
122 | 122 | return true; |
123 | 123 | |
124 | - } catch(Exception\InvalidResponse $e) { |
|
124 | + } catch (Exception\InvalidResponse $e) { |
|
125 | 125 | return false; |
126 | 126 | } |
127 | 127 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | rename($this->getKeyDirectoryPath() . 'public-replacement.pem', $this->getKeyDirectoryPath() . 'public.pem'); |
145 | 145 | return true; |
146 | 146 | |
147 | - } catch(Exception\InvalidResponse $e) { |
|
147 | + } catch (Exception\InvalidResponse $e) { |
|
148 | 148 | |
149 | 149 | return false; |
150 | 150 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | |
164 | 164 | return true; |
165 | 165 | |
166 | - } catch(Exception\InvalidResponse $e) { |
|
166 | + } catch (Exception\InvalidResponse $e) { |
|
167 | 167 | return false; |
168 | 168 | } |
169 | 169 | } |
@@ -83,8 +83,9 @@ discard block |
||
83 | 83 | |
84 | 84 | $account = new self($email); |
85 | 85 | |
86 | - if(!self::exists($email)) |
|
87 | - throw new \RuntimeException('Keys not found - does this account exist?'); |
|
86 | + if(!self::exists($email)) { |
|
87 | + throw new \RuntimeException('Keys not found - does this account exist?'); |
|
88 | + } |
|
88 | 89 | |
89 | 90 | return $account; |
90 | 91 | } |
@@ -116,8 +117,9 @@ discard block |
||
116 | 117 | |
117 | 118 | $this->_setEmail($email); |
118 | 119 | |
119 | - if($previousKeyDirectoryPath != $this->getKeyDirectoryPath()) |
|
120 | - rename($previousKeyDirectoryPath, $this->getKeyDirectoryPath()); |
|
120 | + if($previousKeyDirectoryPath != $this->getKeyDirectoryPath()) { |
|
121 | + rename($previousKeyDirectoryPath, $this->getKeyDirectoryPath()); |
|
122 | + } |
|
121 | 123 | |
122 | 124 | return true; |
123 | 125 |