Completed
Pull Request — master (#8)
by John
02:04
created
src/LEConnector.php 3 patches
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
 	public $keyChange;
48 48
 	public $newAccount;
49
-    public $newNonce;
49
+	public $newNonce;
50 50
 	public $newOrder;
51 51
 	public $revokeCert;
52 52
 
@@ -55,13 +55,13 @@  discard block
 block discarded – undo
55 55
 
56 56
 	private $log;
57 57
 
58
-    /**
59
-     * Initiates the LetsEncrypt Connector class.
60
-     *
61
-     * @param int 		$log			The level of logging. Defaults to no logging. LOG_OFF, LOG_STATUS, LOG_DEBUG accepted.
62
-     * @param string	$baseURL 		The LetsEncrypt server URL to make requests to.
63
-     * @param array		$accountKeys 	Array containing location of account keys files.
64
-     */
58
+	/**
59
+	 * Initiates the LetsEncrypt Connector class.
60
+	 *
61
+	 * @param int 		$log			The level of logging. Defaults to no logging. LOG_OFF, LOG_STATUS, LOG_DEBUG accepted.
62
+	 * @param string	$baseURL 		The LetsEncrypt server URL to make requests to.
63
+	 * @param array		$accountKeys 	Array containing location of account keys files.
64
+	 */
65 65
 	public function __construct($log, $baseURL, $accountKeys)
66 66
 	{
67 67
 		$this->baseURL = $baseURL;
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
 		$this->getNewNonce();
72 72
 	}
73 73
 
74
-    /**
75
-     * Requests the LetsEncrypt Directory and stores the necessary URLs in this LetsEncrypt Connector instance.
76
-     */
74
+	/**
75
+	 * Requests the LetsEncrypt Directory and stores the necessary URLs in this LetsEncrypt Connector instance.
76
+	 */
77 77
 	private function getLEDirectory()
78 78
 	{
79 79
 		$req = $this->get('/directory');
@@ -84,42 +84,42 @@  discard block
 block discarded – undo
84 84
 		$this->revokeCert = $req['body']['revokeCert'];
85 85
 	}
86 86
 
87
-    /**
88
-     * Requests a new nonce from the LetsEncrypt server and stores it in this LetsEncrypt Connector instance.
89
-     */
87
+	/**
88
+	 * Requests a new nonce from the LetsEncrypt server and stores it in this LetsEncrypt Connector instance.
89
+	 */
90 90
 	private function getNewNonce()
91 91
 	{
92 92
 		if($this->head($this->newNonce)['status'] !== 200) throw LEConnectorException::NoNewNonceException();
93 93
 	}
94 94
 
95
-    /**
96
-     * Makes a Curl request.
97
-     *
98
-     * @param string	$method	The HTTP method to use. Accepting GET, POST and HEAD requests.
99
-     * @param string 	$URL 	The URL or partial URL to make the request to. If it is partial, the baseURL will be prepended.
100
-     * @param object 	$data  	The body to attach to a POST request. Expected as a JSON encoded string.
101
-     *
102
-     * @return array 	Returns an array with the keys 'request', 'header', 'status' and 'body'.
103
-     */
95
+	/**
96
+	 * Makes a Curl request.
97
+	 *
98
+	 * @param string	$method	The HTTP method to use. Accepting GET, POST and HEAD requests.
99
+	 * @param string 	$URL 	The URL or partial URL to make the request to. If it is partial, the baseURL will be prepended.
100
+	 * @param object 	$data  	The body to attach to a POST request. Expected as a JSON encoded string.
101
+	 *
102
+	 * @return array 	Returns an array with the keys 'request', 'header', 'status' and 'body'.
103
+	 */
104 104
 	private function request($method, $URL, $data = null)
105 105
 	{
106 106
 		if($this->accountDeactivated) throw LEConnectorException::AccountDeactivatedException();
107 107
 
108 108
 		$headers = array('Accept: application/json', 'Content-Type: application/jose+json');
109 109
 		$requestURL = preg_match('~^http~', $URL) ? $URL : $this->baseURL . $URL;
110
-        $handle = curl_init();
111
-        curl_setopt($handle, CURLOPT_URL, $requestURL);
112
-        curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
113
-        curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
114
-        curl_setopt($handle, CURLOPT_HEADER, true);
115
-
116
-        switch ($method) {
117
-            case 'GET':
118
-                break;
119
-            case 'POST':
120
-                curl_setopt($handle, CURLOPT_POST, true);
121
-                curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
122
-                break;
110
+		$handle = curl_init();
111
+		curl_setopt($handle, CURLOPT_URL, $requestURL);
112
+		curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
113
+		curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
114
+		curl_setopt($handle, CURLOPT_HEADER, true);
115
+
116
+		switch ($method) {
117
+			case 'GET':
118
+				break;
119
+			case 'POST':
120
+				curl_setopt($handle, CURLOPT_POST, true);
121
+				curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
122
+				break;
123 123
 			case 'HEAD':
124 124
 				curl_setopt($handle, CURLOPT_CUSTOMREQUEST, 'HEAD');
125 125
 				curl_setopt($handle, CURLOPT_NOBODY, true);
@@ -127,25 +127,25 @@  discard block
 block discarded – undo
127 127
 			default:
128 128
 				throw LEConnectorException::MethodNotSupportedException($method);
129 129
 				break;
130
-        }
131
-        $response = curl_exec($handle);
130
+		}
131
+		$response = curl_exec($handle);
132 132
 
133
-        if(curl_errno($handle)) {
134
-            throw LEConnectorException::CurlErrorException(curl_error($handle));
135
-        }
133
+		if(curl_errno($handle)) {
134
+			throw LEConnectorException::CurlErrorException(curl_error($handle));
135
+		}
136 136
 
137
-        $headerSize = curl_getinfo($handle, CURLINFO_HEADER_SIZE);
138
-        $statusCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
137
+		$headerSize = curl_getinfo($handle, CURLINFO_HEADER_SIZE);
138
+		$statusCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
139 139
 
140
-        $header = substr($response, 0, $headerSize);
141
-        $body = substr($response, $headerSize);
140
+		$header = substr($response, 0, $headerSize);
141
+		$body = substr($response, $headerSize);
142 142
 		$jsonbody = json_decode($body, true);
143 143
 		$jsonresponse = array(
144
-            'request' => $method . ' ' . $requestURL,
145
-            'header' => $header,
146
-            'status' => $statusCode,
147
-            'body' => $jsonbody === null ? $body : $jsonbody,
148
-        );
144
+			'request' => $method . ' ' . $requestURL,
145
+			'header' => $header,
146
+			'status' => $statusCode,
147
+			'body' => $jsonbody === null ? $body : $jsonbody,
148
+		);
149 149
 		if($this->log instanceof \Psr\Log\LoggerInterface) 
150 150
 		{
151 151
 			$this->log->debug($method . ' response received', $jsonresponse);
@@ -167,122 +167,122 @@  discard block
 block discarded – undo
167 167
 			throw LEConnectorException::InvalidResponseException($jsonresponse);
168 168
 		}
169 169
 
170
-        return $jsonresponse;
170
+		return $jsonresponse;
171 171
 	}
172 172
 
173
-    /**
174
-     * Makes a GET request.
175
-     *
176
-     * @param string	$url 	The URL or partial URL to make the request to. If it is partial, the baseURL will be prepended.
177
-     *
178
-     * @return array 	Returns an array with the keys 'request', 'header', 'status' and 'body'.
179
-     */
173
+	/**
174
+	 * Makes a GET request.
175
+	 *
176
+	 * @param string	$url 	The URL or partial URL to make the request to. If it is partial, the baseURL will be prepended.
177
+	 *
178
+	 * @return array 	Returns an array with the keys 'request', 'header', 'status' and 'body'.
179
+	 */
180 180
 	public function get($url)
181 181
 	{
182 182
 		return $this->request('GET', $url);
183 183
 	}
184 184
 
185 185
 	/**
186
-     * Makes a POST request.
187
-     *
188
-     * @param string 	$url	The URL or partial URL to make the request to. If it is partial, the baseURL will be prepended.
186
+	 * Makes a POST request.
187
+	 *
188
+	 * @param string 	$url	The URL or partial URL to make the request to. If it is partial, the baseURL will be prepended.
189 189
 	 * @param object 	$data	The body to attach to a POST request. Expected as a json string.
190
-     *
191
-     * @return array 	Returns an array with the keys 'request', 'header', 'status' and 'body'.
192
-     */
190
+	 *
191
+	 * @return array 	Returns an array with the keys 'request', 'header', 'status' and 'body'.
192
+	 */
193 193
 	public function post($url, $data = null)
194 194
 	{
195 195
 		return $this->request('POST', $url, $data);
196 196
 	}
197 197
 
198 198
 	/**
199
-     * Makes a HEAD request.
200
-     *
201
-     * @param string 	$url	The URL or partial URL to make the request to. If it is partial, the baseURL will be prepended.
202
-     *
203
-     * @return array	Returns an array with the keys 'request', 'header', 'status' and 'body'.
204
-     */
199
+	 * Makes a HEAD request.
200
+	 *
201
+	 * @param string 	$url	The URL or partial URL to make the request to. If it is partial, the baseURL will be prepended.
202
+	 *
203
+	 * @return array	Returns an array with the keys 'request', 'header', 'status' and 'body'.
204
+	 */
205 205
 	public function head($url)
206 206
 	{
207 207
 		return $this->request('HEAD', $url);
208 208
 	}
209 209
 
210
-    /**
211
-     * Generates a JSON Web Key signature to attach to the request.
212
-     *
213
-     * @param array 	$payload		The payload to add to the signature.
214
-     * @param string	$url 			The URL to use in the signature.
215
-     * @param string 	$privateKeyFile The private key to sign the request with. Defaults to 'private.pem'. Defaults to accountKeys[private_key].
216
-     *
217
-     * @return string	Returns a JSON encoded string containing the signature.
218
-     */
210
+	/**
211
+	 * Generates a JSON Web Key signature to attach to the request.
212
+	 *
213
+	 * @param array 	$payload		The payload to add to the signature.
214
+	 * @param string	$url 			The URL to use in the signature.
215
+	 * @param string 	$privateKeyFile The private key to sign the request with. Defaults to 'private.pem'. Defaults to accountKeys[private_key].
216
+	 *
217
+	 * @return string	Returns a JSON encoded string containing the signature.
218
+	 */
219 219
 	public function signRequestJWK($payload, $url, $privateKeyFile = '')
220
-    {
220
+	{
221 221
 		if($privateKeyFile == '') $privateKeyFile = $this->accountKeys['private_key'];
222 222
 		$privateKey = openssl_pkey_get_private(file_get_contents($privateKeyFile));
223
-        $details = openssl_pkey_get_details($privateKey);
224
-
225
-        $protected = array(
226
-            "alg" => "RS256",
227
-            "jwk" => array(
228
-                "kty" => "RSA",
229
-                "n" => LEFunctions::Base64UrlSafeEncode($details["rsa"]["n"]),
230
-                "e" => LEFunctions::Base64UrlSafeEncode($details["rsa"]["e"]),
231
-            ),
223
+		$details = openssl_pkey_get_details($privateKey);
224
+
225
+		$protected = array(
226
+			"alg" => "RS256",
227
+			"jwk" => array(
228
+				"kty" => "RSA",
229
+				"n" => LEFunctions::Base64UrlSafeEncode($details["rsa"]["n"]),
230
+				"e" => LEFunctions::Base64UrlSafeEncode($details["rsa"]["e"]),
231
+			),
232 232
 			"nonce" => $this->nonce,
233 233
 			"url" => $url
234
-        );
234
+		);
235 235
 
236
-        $payload64 = LEFunctions::Base64UrlSafeEncode(str_replace('\\/', '/', is_array($payload) ? json_encode($payload) : $payload));
237
-        $protected64 = LEFunctions::Base64UrlSafeEncode(json_encode($protected));
236
+		$payload64 = LEFunctions::Base64UrlSafeEncode(str_replace('\\/', '/', is_array($payload) ? json_encode($payload) : $payload));
237
+		$protected64 = LEFunctions::Base64UrlSafeEncode(json_encode($protected));
238 238
 
239
-        openssl_sign($protected64.'.'.$payload64, $signed, $privateKey, "SHA256");
240
-        $signed64 = LEFunctions::Base64UrlSafeEncode($signed);
239
+		openssl_sign($protected64.'.'.$payload64, $signed, $privateKey, "SHA256");
240
+		$signed64 = LEFunctions::Base64UrlSafeEncode($signed);
241 241
 
242
-        $data = array(
243
-            'protected' => $protected64,
244
-            'payload' => $payload64,
245
-            'signature' => $signed64
246
-        );
242
+		$data = array(
243
+			'protected' => $protected64,
244
+			'payload' => $payload64,
245
+			'signature' => $signed64
246
+		);
247 247
 
248
-        return json_encode($data);
249
-    }
248
+		return json_encode($data);
249
+	}
250 250
 
251 251
 	/**
252
-     * Generates a Key ID signature to attach to the request.
253
-     *
254
-     * @param array 	$payload		The payload to add to the signature.
252
+	 * Generates a Key ID signature to attach to the request.
253
+	 *
254
+	 * @param array 	$payload		The payload to add to the signature.
255 255
 	 * @param string	$kid			The Key ID to use in the signature.
256
-     * @param string	$url 			The URL to use in the signature.
257
-     * @param string 	$privateKeyFile The private key to sign the request with. Defaults to 'private.pem'. Defaults to accountKeys[private_key].
258
-     *
259
-     * @return string	Returns a JSON encoded string containing the signature.
260
-     */
256
+	 * @param string	$url 			The URL to use in the signature.
257
+	 * @param string 	$privateKeyFile The private key to sign the request with. Defaults to 'private.pem'. Defaults to accountKeys[private_key].
258
+	 *
259
+	 * @return string	Returns a JSON encoded string containing the signature.
260
+	 */
261 261
 	public function signRequestKid($payload, $kid, $url, $privateKeyFile = '')
262
-    {
262
+	{
263 263
 		if($privateKeyFile == '') $privateKeyFile = $this->accountKeys['private_key'];
264
-        $privateKey = openssl_pkey_get_private(file_get_contents($privateKeyFile));
265
-        $details = openssl_pkey_get_details($privateKey);
264
+		$privateKey = openssl_pkey_get_private(file_get_contents($privateKeyFile));
265
+		$details = openssl_pkey_get_details($privateKey);
266 266
 
267
-        $protected = array(
268
-            "alg" => "RS256",
269
-            "kid" => $kid,
267
+		$protected = array(
268
+			"alg" => "RS256",
269
+			"kid" => $kid,
270 270
 			"nonce" => $this->nonce,
271 271
 			"url" => $url
272
-        );
272
+		);
273 273
 
274
-        $payload64 = LEFunctions::Base64UrlSafeEncode(str_replace('\\/', '/', is_array($payload) ? json_encode($payload) : $payload));
275
-        $protected64 = LEFunctions::Base64UrlSafeEncode(json_encode($protected));
274
+		$payload64 = LEFunctions::Base64UrlSafeEncode(str_replace('\\/', '/', is_array($payload) ? json_encode($payload) : $payload));
275
+		$protected64 = LEFunctions::Base64UrlSafeEncode(json_encode($protected));
276 276
 
277
-        openssl_sign($protected64.'.'.$payload64, $signed, $privateKey, "SHA256");
278
-        $signed64 = LEFunctions::Base64UrlSafeEncode($signed);
277
+		openssl_sign($protected64.'.'.$payload64, $signed, $privateKey, "SHA256");
278
+		$signed64 = LEFunctions::Base64UrlSafeEncode($signed);
279 279
 
280
-        $data = array(
281
-            'protected' => $protected64,
282
-            'payload' => $payload64,
283
-            'signature' => $signed64
284
-        );
280
+		$data = array(
281
+			'protected' => $protected64,
282
+			'payload' => $payload64,
283
+			'signature' => $signed64
284
+		);
285 285
 
286
-        return json_encode($data);
287
-    }
286
+		return json_encode($data);
287
+	}
288 288
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
      */
90 90
 	private function getNewNonce()
91 91
 	{
92
-		if($this->head($this->newNonce)['status'] !== 200) throw LEConnectorException::NoNewNonceException();
92
+		if ($this->head($this->newNonce)['status'] !== 200) throw LEConnectorException::NoNewNonceException();
93 93
 	}
94 94
 
95 95
     /**
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      */
104 104
 	private function request($method, $URL, $data = null)
105 105
 	{
106
-		if($this->accountDeactivated) throw LEConnectorException::AccountDeactivatedException();
106
+		if ($this->accountDeactivated) throw LEConnectorException::AccountDeactivatedException();
107 107
 
108 108
 		$headers = array('Accept: application/json', 'Content-Type: application/jose+json');
109 109
 		$requestURL = preg_match('~^http~', $URL) ? $URL : $this->baseURL . $URL;
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
         }
131 131
         $response = curl_exec($handle);
132 132
 
133
-        if(curl_errno($handle)) {
133
+        if (curl_errno($handle)) {
134 134
             throw LEConnectorException::CurlErrorException(curl_error($handle));
135 135
         }
136 136
 
@@ -146,22 +146,22 @@  discard block
 block discarded – undo
146 146
             'status' => $statusCode,
147 147
             'body' => $jsonbody === null ? $body : $jsonbody,
148 148
         );
149
-		if($this->log instanceof \Psr\Log\LoggerInterface) 
149
+		if ($this->log instanceof \Psr\Log\LoggerInterface) 
150 150
 		{
151 151
 			$this->log->debug($method . ' response received', $jsonresponse);
152 152
 		}
153
-		elseif($this->log >= LEClient::LOG_DEBUG) LEFunctions::log($jsonresponse);
153
+		elseif ($this->log >= LEClient::LOG_DEBUG) LEFunctions::log($jsonresponse);
154 154
 		
155
-		if(preg_match('~Replay\-Nonce: (\S+)~i', $header, $matches))
155
+		if (preg_match('~Replay\-Nonce: (\S+)~i', $header, $matches))
156 156
 		{
157 157
 			$this->nonce = trim($matches[1]);
158 158
 		}
159 159
 		else
160 160
 		{
161
-			if($method == 'POST') $this->getNewNonce(); // Not expecting a new nonce with GET and HEAD requests.
161
+			if ($method == 'POST') $this->getNewNonce(); // Not expecting a new nonce with GET and HEAD requests.
162 162
 		}
163 163
 
164
-		if((($method == 'POST' OR $method == 'GET') AND $statusCode !== 200 AND $statusCode !== 201) OR
164
+		if ((($method == 'POST' OR $method == 'GET') AND $statusCode !== 200 AND $statusCode !== 201) OR
165 165
 			($method == 'HEAD' AND $statusCode !== 200))
166 166
 		{
167 167
 			throw LEConnectorException::InvalidResponseException($jsonresponse);
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
      */
219 219
 	public function signRequestJWK($payload, $url, $privateKeyFile = '')
220 220
     {
221
-		if($privateKeyFile == '') $privateKeyFile = $this->accountKeys['private_key'];
221
+		if ($privateKeyFile == '') $privateKeyFile = $this->accountKeys['private_key'];
222 222
 		$privateKey = openssl_pkey_get_private(file_get_contents($privateKeyFile));
223 223
         $details = openssl_pkey_get_details($privateKey);
224 224
 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
         $payload64 = LEFunctions::Base64UrlSafeEncode(str_replace('\\/', '/', is_array($payload) ? json_encode($payload) : $payload));
237 237
         $protected64 = LEFunctions::Base64UrlSafeEncode(json_encode($protected));
238 238
 
239
-        openssl_sign($protected64.'.'.$payload64, $signed, $privateKey, "SHA256");
239
+        openssl_sign($protected64 . '.' . $payload64, $signed, $privateKey, "SHA256");
240 240
         $signed64 = LEFunctions::Base64UrlSafeEncode($signed);
241 241
 
242 242
         $data = array(
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
      */
261 261
 	public function signRequestKid($payload, $kid, $url, $privateKeyFile = '')
262 262
     {
263
-		if($privateKeyFile == '') $privateKeyFile = $this->accountKeys['private_key'];
263
+		if ($privateKeyFile == '') $privateKeyFile = $this->accountKeys['private_key'];
264 264
         $privateKey = openssl_pkey_get_private(file_get_contents($privateKeyFile));
265 265
         $details = openssl_pkey_get_details($privateKey);
266 266
 
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
         $payload64 = LEFunctions::Base64UrlSafeEncode(str_replace('\\/', '/', is_array($payload) ? json_encode($payload) : $payload));
275 275
         $protected64 = LEFunctions::Base64UrlSafeEncode(json_encode($protected));
276 276
 
277
-        openssl_sign($protected64.'.'.$payload64, $signed, $privateKey, "SHA256");
277
+        openssl_sign($protected64 . '.' . $payload64, $signed, $privateKey, "SHA256");
278 278
         $signed64 = LEFunctions::Base64UrlSafeEncode($signed);
279 279
 
280 280
         $data = array(
Please login to merge, or discard this patch.
Braces   +19 added lines, -8 removed lines patch added patch discarded remove patch
@@ -89,7 +89,9 @@  discard block
 block discarded – undo
89 89
      */
90 90
 	private function getNewNonce()
91 91
 	{
92
-		if($this->head($this->newNonce)['status'] !== 200) throw LEConnectorException::NoNewNonceException();
92
+		if($this->head($this->newNonce)['status'] !== 200) {
93
+			throw LEConnectorException::NoNewNonceException();
94
+		}
93 95
 	}
94 96
 
95 97
     /**
@@ -103,7 +105,9 @@  discard block
 block discarded – undo
103 105
      */
104 106
 	private function request($method, $URL, $data = null)
105 107
 	{
106
-		if($this->accountDeactivated) throw LEConnectorException::AccountDeactivatedException();
108
+		if($this->accountDeactivated) {
109
+			throw LEConnectorException::AccountDeactivatedException();
110
+		}
107 111
 
108 112
 		$headers = array('Accept: application/json', 'Content-Type: application/jose+json');
109 113
 		$requestURL = preg_match('~^http~', $URL) ? $URL : $this->baseURL . $URL;
@@ -149,16 +153,19 @@  discard block
 block discarded – undo
149 153
 		if($this->log instanceof \Psr\Log\LoggerInterface) 
150 154
 		{
151 155
 			$this->log->debug($method . ' response received', $jsonresponse);
156
+		} elseif($this->log >= LEClient::LOG_DEBUG) {
157
+			LEFunctions::log($jsonresponse);
152 158
 		}
153
-		elseif($this->log >= LEClient::LOG_DEBUG) LEFunctions::log($jsonresponse);
154 159
 		
155 160
 		if(preg_match('~Replay\-Nonce: (\S+)~i', $header, $matches))
156 161
 		{
157 162
 			$this->nonce = trim($matches[1]);
158
-		}
159
-		else
163
+		} else
160 164
 		{
161
-			if($method == 'POST') $this->getNewNonce(); // Not expecting a new nonce with GET and HEAD requests.
165
+			if($method == 'POST') {
166
+				$this->getNewNonce();
167
+			}
168
+			// Not expecting a new nonce with GET and HEAD requests.
162 169
 		}
163 170
 
164 171
 		if((($method == 'POST' OR $method == 'GET') AND $statusCode !== 200 AND $statusCode !== 201) OR
@@ -218,7 +225,9 @@  discard block
 block discarded – undo
218 225
      */
219 226
 	public function signRequestJWK($payload, $url, $privateKeyFile = '')
220 227
     {
221
-		if($privateKeyFile == '') $privateKeyFile = $this->accountKeys['private_key'];
228
+		if($privateKeyFile == '') {
229
+			$privateKeyFile = $this->accountKeys['private_key'];
230
+		}
222 231
 		$privateKey = openssl_pkey_get_private(file_get_contents($privateKeyFile));
223 232
         $details = openssl_pkey_get_details($privateKey);
224 233
 
@@ -260,7 +269,9 @@  discard block
 block discarded – undo
260 269
      */
261 270
 	public function signRequestKid($payload, $kid, $url, $privateKeyFile = '')
262 271
     {
263
-		if($privateKeyFile == '') $privateKeyFile = $this->accountKeys['private_key'];
272
+		if($privateKeyFile == '') {
273
+			$privateKeyFile = $this->accountKeys['private_key'];
274
+		}
264 275
         $privateKey = openssl_pkey_get_private(file_get_contents($privateKeyFile));
265 276
         $details = openssl_pkey_get_details($privateKey);
266 277
 
Please login to merge, or discard this patch.
src/LEAccount.php 3 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -52,14 +52,14 @@  discard block
 block discarded – undo
52 52
 
53 53
 	private $log;
54 54
 
55
-    /**
56
-     * Initiates the LetsEncrypt Account class.
57
-     *
58
-     * @param LEConnector	$connector 		The LetsEncrypt Connector instance to use for HTTP requests.
59
-     * @param int 			$log 			The level of logging. Defaults to no logging. LOG_OFF, LOG_STATUS, LOG_DEBUG accepted.
60
-     * @param array 		$email	 		The array of strings containing e-mail addresses. Only used when creating a new account.
61
-     * @param array 		$accountKeys 	Array containing location of account keys files.
62
-     */
55
+	/**
56
+	 * Initiates the LetsEncrypt Account class.
57
+	 *
58
+	 * @param LEConnector	$connector 		The LetsEncrypt Connector instance to use for HTTP requests.
59
+	 * @param int 			$log 			The level of logging. Defaults to no logging. LOG_OFF, LOG_STATUS, LOG_DEBUG accepted.
60
+	 * @param array 		$email	 		The array of strings containing e-mail addresses. Only used when creating a new account.
61
+	 * @param array 		$accountKeys 	Array containing location of account keys files.
62
+	 */
63 63
 	public function __construct($connector, $log, $email, $accountKeys)
64 64
 	{
65 65
 		$this->connector = $connector;
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
 		$this->getLEAccountData();
86 86
 	}
87 87
 
88
-    /**
89
-     * Creates a new LetsEncrypt account.
90
-     *
91
-     * @param array 	$email 	The array of strings containing e-mail addresses.
92
-     *
93
-     * @return object	Returns the new account URL when the account was successfully created, false if not.
94
-     */
88
+	/**
89
+	 * Creates a new LetsEncrypt account.
90
+	 *
91
+	 * @param array 	$email 	The array of strings containing e-mail addresses.
92
+	 *
93
+	 * @return object	Returns the new account URL when the account was successfully created, false if not.
94
+	 */
95 95
 	private function createLEAccount($email)
96 96
 	{
97 97
 		$contact = array_map(function($addr) { return empty($addr) ? '' : (strpos($addr, 'mailto') === false ? 'mailto:' . $addr : $addr); }, $email);
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
 		return false;
106 106
 	}
107 107
 
108
-    /**
109
-     * Gets the LetsEncrypt account URL associated with the stored account keys.
110
-     *
111
-     * @return object	Returns the account URL if it is found, or false when none is found.
112
-     */
108
+	/**
109
+	 * Gets the LetsEncrypt account URL associated with the stored account keys.
110
+	 *
111
+	 * @return object	Returns the account URL if it is found, or false when none is found.
112
+	 */
113 113
 	private function getLEAccount()
114 114
 	{
115 115
 		$sign = $this->connector->signRequestJWK(array('onlyReturnExisting' => true), $this->connector->newAccount);
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 		return false;
123 123
 	}
124 124
 
125
-    /**
126
-     * Gets the LetsEncrypt account data from the account URL.
127
-     */
125
+	/**
126
+	 * Gets the LetsEncrypt account data from the account URL.
127
+	 */
128 128
 	private function getLEAccountData()
129 129
 	{
130 130
 		$sign = $this->connector->signRequestKid(array('' => ''), $this->connector->accountURL, $this->connector->accountURL);
@@ -145,13 +145,13 @@  discard block
 block discarded – undo
145 145
 		}
146 146
 	}
147 147
 
148
-    /**
149
-     * Updates account data. Now just supporting new contact information.
150
-     *
151
-     * @param array 	$email	The array of strings containing e-mail adresses.
152
-     *
153
-     * @return boolean	Returns true if the update is successful, false if not.
154
-     */
148
+	/**
149
+	 * Updates account data. Now just supporting new contact information.
150
+	 *
151
+	 * @param array 	$email	The array of strings containing e-mail adresses.
152
+	 *
153
+	 * @return boolean	Returns true if the update is successful, false if not.
154
+	 */
155 155
 	public function updateAccount($email)
156 156
 	{
157 157
 		$contact = array_map(function($addr) { return empty($addr) ? '' : (strpos($addr, 'mailto') === false ? 'mailto:' . $addr : $addr); }, $email);
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
 		}
181 181
 	}
182 182
 
183
-    /**
184
-     * Creates new RSA account keys and updates the keys with LetsEncrypt.
185
-     *
186
-     * @return boolean	Returns true if the update is successful, false if not.
187
-     */
183
+	/**
184
+	 * Creates new RSA account keys and updates the keys with LetsEncrypt.
185
+	 *
186
+	 * @return boolean	Returns true if the update is successful, false if not.
187
+	 */
188 188
 	public function changeAccountKeys()
189 189
 	{
190 190
 		LEFunctions::RSAgenerateKeys(null, $this->accountKeys['private_key'].'.new', $this->accountKeys['public_key'].'.new');
@@ -220,11 +220,11 @@  discard block
 block discarded – undo
220 220
 		}
221 221
 	}
222 222
 
223
-    /**
224
-     * Deactivates the LetsEncrypt account.
225
-     *
226
-     * @return boolean	Returns true if the deactivation is successful, false if not.
227
-     */
223
+	/**
224
+	 * Deactivates the LetsEncrypt account.
225
+	 *
226
+	 * @return boolean	Returns true if the deactivation is successful, false if not.
227
+	 */
228 228
 	public function deactivateAccount()
229 229
 	{
230 230
 		$sign = $this->connector->signRequestKid(array('status' => 'deactivated'), $this->connector->accountURL, $this->connector->accountURL);
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
 		$this->accountKeys = $accountKeys;
67 67
 		$this->log = $log;
68 68
 
69
-		if(!file_exists($this->accountKeys['private_key']) OR !file_exists($this->accountKeys['public_key']))
69
+		if (!file_exists($this->accountKeys['private_key']) OR !file_exists($this->accountKeys['public_key']))
70 70
 		{
71
-			if($this->log instanceof \Psr\Log\LoggerInterface) 
71
+			if ($this->log instanceof \Psr\Log\LoggerInterface) 
72 72
 			{
73 73
 				$this->log->info('No account found, attempting to create account.');
74 74
 			}
75
-			else if($this->log >= LECLient::LOG_STATUS) LEFunctions::log('No account found, attempting to create account.', 'function LEAccount __construct');
75
+			else if ($this->log >= LECLient::LOG_STATUS) LEFunctions::log('No account found, attempting to create account.', 'function LEAccount __construct');
76 76
 			
77 77
 			LEFunctions::RSAgenerateKeys(null, $this->accountKeys['private_key'], $this->accountKeys['public_key']);
78 78
 			$this->connector->accountURL = $this->createLEAccount($email);
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 		{
82 82
 			$this->connector->accountURL = $this->getLEAccount();
83 83
 		}
84
-		if($this->connector->accountURL == false) throw LEAccountException::AccountNotFoundException();
84
+		if ($this->connector->accountURL == false) throw LEAccountException::AccountNotFoundException();
85 85
 		$this->getLEAccountData();
86 86
 	}
87 87
 
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
 
99 99
 		$sign = $this->connector->signRequestJWK(array('contact' => $contact, 'termsOfServiceAgreed' => true), $this->connector->newAccount);
100 100
 		$post = $this->connector->post($this->connector->newAccount, $sign);
101
-		if($post['status'] === 201)
101
+		if ($post['status'] === 201)
102 102
 		{
103
-			if(preg_match('~Location: (\S+)~i', $post['header'], $matches)) return trim($matches[1]);
103
+			if (preg_match('~Location: (\S+)~i', $post['header'], $matches)) return trim($matches[1]);
104 104
 		}
105 105
 		return false;
106 106
 	}
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
 		$sign = $this->connector->signRequestJWK(array('onlyReturnExisting' => true), $this->connector->newAccount);
116 116
 		$post = $this->connector->post($this->connector->newAccount, $sign);
117 117
 
118
-		if($post['status'] === 200)
118
+		if ($post['status'] === 200)
119 119
 		{
120
-			if(preg_match('~Location: (\S+)~i', $post['header'], $matches)) return trim($matches[1]);
120
+			if (preg_match('~Location: (\S+)~i', $post['header'], $matches)) return trim($matches[1]);
121 121
 		}
122 122
 		return false;
123 123
 	}
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	{
130 130
 		$sign = $this->connector->signRequestKid(array('' => ''), $this->connector->accountURL, $this->connector->accountURL);
131 131
 		$post = $this->connector->post($this->connector->accountURL, $sign);
132
-		if($post['status'] === 200)
132
+		if ($post['status'] === 200)
133 133
 		{
134 134
 			$this->id = isset($post['body']['id']) ? $post['body']['id'] : '';
135 135
 			$this->key = $post['body']['key'];
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
 		$sign = $this->connector->signRequestKid(array('contact' => $contact), $this->connector->accountURL, $this->connector->accountURL);
160 160
 		$post = $this->connector->post($this->connector->accountURL, $sign);
161
-		if($post['status'] === 200)
161
+		if ($post['status'] === 200)
162 162
 		{
163 163
 			$this->id = isset($post['body']['id']) ? $post['body']['id'] : '';
164 164
 			$this->key = $post['body']['key'];
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
 			$this->initialIp = $post['body']['initialIp'];
168 168
 			$this->createdAt = $post['body']['createdAt'];
169 169
 			$this->status = $post['body']['status'];
170
-			if($this->log instanceof \Psr\Log\LoggerInterface) 
170
+			if ($this->log instanceof \Psr\Log\LoggerInterface) 
171 171
 			{
172 172
 				$this->log->info('Account data updated.');
173 173
 			}
174
-			else if($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Account data updated.', 'function updateAccount');
174
+			else if ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Account data updated.', 'function updateAccount');
175 175
 			return true;
176 176
 		}
177 177
 		else
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
      */
188 188
 	public function changeAccountKeys()
189 189
 	{
190
-		LEFunctions::RSAgenerateKeys(null, $this->accountKeys['private_key'].'.new', $this->accountKeys['public_key'].'.new');
190
+		LEFunctions::RSAgenerateKeys(null, $this->accountKeys['private_key'] . '.new', $this->accountKeys['public_key'] . '.new');
191 191
 		$oldPrivateKey = openssl_pkey_get_private(file_get_contents($this->accountKeys['private_key']));
192 192
 		$oldDetails = openssl_pkey_get_details($oldPrivateKey);
193 193
 		$innerPayload = array('account' => $this->connector->accountURL, 'oldKey' => array(
@@ -195,23 +195,23 @@  discard block
 block discarded – undo
195 195
 			"n" => LEFunctions::Base64UrlSafeEncode($oldDetails["rsa"]["n"]),
196 196
 			"e" => LEFunctions::Base64UrlSafeEncode($oldDetails["rsa"]["e"])
197 197
 		));
198
-		$outerPayload = $this->connector->signRequestJWK($innerPayload, $this->connector->keyChange, $this->accountKeys['private_key'].'.new');
198
+		$outerPayload = $this->connector->signRequestJWK($innerPayload, $this->connector->keyChange, $this->accountKeys['private_key'] . '.new');
199 199
 		$sign = $this->connector->signRequestKid($outerPayload, $this->connector->accountURL, $this->connector->keyChange);
200 200
 		$post = $this->connector->post($this->connector->keyChange, $sign);
201
-		if($post['status'] === 200)
201
+		if ($post['status'] === 200)
202 202
 		{
203 203
 			unlink($this->accountKeys['private_key']);
204 204
 			unlink($this->accountKeys['public_key']);
205
-			rename($this->accountKeys['private_key'].'.new', $this->accountKeys['private_key']);
206
-			rename($this->accountKeys['public_key'].'.new', $this->accountKeys['public_key']);
205
+			rename($this->accountKeys['private_key'] . '.new', $this->accountKeys['private_key']);
206
+			rename($this->accountKeys['public_key'] . '.new', $this->accountKeys['public_key']);
207 207
 			
208 208
 			$this->getLEAccountData();
209 209
 
210
-			if($this->log instanceof \Psr\Log\LoggerInterface) 
210
+			if ($this->log instanceof \Psr\Log\LoggerInterface) 
211 211
 			{
212 212
 				$this->log->info('Account keys changed.');
213 213
 			}
214
-			elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Account keys changed.', 'function changeAccountKey');
214
+			elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Account keys changed.', 'function changeAccountKey');
215 215
 			return true;
216 216
 		}
217 217
 		else
@@ -229,14 +229,14 @@  discard block
 block discarded – undo
229 229
 	{
230 230
 		$sign = $this->connector->signRequestKid(array('status' => 'deactivated'), $this->connector->accountURL, $this->connector->accountURL);
231 231
 		$post = $this->connector->post($this->connector->accountURL, $sign);
232
-		if($post['status'] === 200)
232
+		if ($post['status'] === 200)
233 233
 		{
234 234
 			$this->connector->accountDeactivated = true;
235
-			if($this->log instanceof \Psr\Log\LoggerInterface) 
235
+			if ($this->log instanceof \Psr\Log\LoggerInterface) 
236 236
 			{
237 237
 				$this->log->info('Account deactivated.');
238 238
 			}
239
-			elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Account deactivated.', 'function deactivateAccount');
239
+			elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Account deactivated.', 'function deactivateAccount');
240 240
 			
241 241
 			return true;
242 242
 		}
Please login to merge, or discard this patch.
Braces   +22 added lines, -17 removed lines patch added patch discarded remove patch
@@ -71,17 +71,19 @@  discard block
 block discarded – undo
71 71
 			if($this->log instanceof \Psr\Log\LoggerInterface) 
72 72
 			{
73 73
 				$this->log->info('No account found, attempting to create account.');
74
+			} else if($this->log >= LECLient::LOG_STATUS) {
75
+				LEFunctions::log('No account found, attempting to create account.', 'function LEAccount __construct');
74 76
 			}
75
-			else if($this->log >= LECLient::LOG_STATUS) LEFunctions::log('No account found, attempting to create account.', 'function LEAccount __construct');
76 77
 			
77 78
 			LEFunctions::RSAgenerateKeys(null, $this->accountKeys['private_key'], $this->accountKeys['public_key']);
78 79
 			$this->connector->accountURL = $this->createLEAccount($email);
79
-		}
80
-		else
80
+		} else
81 81
 		{
82 82
 			$this->connector->accountURL = $this->getLEAccount();
83 83
 		}
84
-		if($this->connector->accountURL == false) throw LEAccountException::AccountNotFoundException();
84
+		if($this->connector->accountURL == false) {
85
+			throw LEAccountException::AccountNotFoundException();
86
+		}
85 87
 		$this->getLEAccountData();
86 88
 	}
87 89
 
@@ -100,7 +102,9 @@  discard block
 block discarded – undo
100 102
 		$post = $this->connector->post($this->connector->newAccount, $sign);
101 103
 		if($post['status'] === 201)
102 104
 		{
103
-			if(preg_match('~Location: (\S+)~i', $post['header'], $matches)) return trim($matches[1]);
105
+			if(preg_match('~Location: (\S+)~i', $post['header'], $matches)) {
106
+				return trim($matches[1]);
107
+			}
104 108
 		}
105 109
 		return false;
106 110
 	}
@@ -117,7 +121,9 @@  discard block
 block discarded – undo
117 121
 
118 122
 		if($post['status'] === 200)
119 123
 		{
120
-			if(preg_match('~Location: (\S+)~i', $post['header'], $matches)) return trim($matches[1]);
124
+			if(preg_match('~Location: (\S+)~i', $post['header'], $matches)) {
125
+				return trim($matches[1]);
126
+			}
121 127
 		}
122 128
 		return false;
123 129
 	}
@@ -138,8 +144,7 @@  discard block
 block discarded – undo
138 144
 			$this->initialIp = $post['body']['initialIp'];
139 145
 			$this->createdAt = $post['body']['createdAt'];
140 146
 			$this->status = $post['body']['status'];
141
-		}
142
-		else
147
+		} else
143 148
 		{
144 149
 			throw LEAccountException::AccountNotFoundException();
145 150
 		}
@@ -170,11 +175,11 @@  discard block
 block discarded – undo
170 175
 			if($this->log instanceof \Psr\Log\LoggerInterface) 
171 176
 			{
172 177
 				$this->log->info('Account data updated.');
178
+			} else if($this->log >= LEClient::LOG_STATUS) {
179
+				LEFunctions::log('Account data updated.', 'function updateAccount');
173 180
 			}
174
-			else if($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Account data updated.', 'function updateAccount');
175 181
 			return true;
176
-		}
177
-		else
182
+		} else
178 183
 		{
179 184
 			return false;
180 185
 		}
@@ -210,11 +215,11 @@  discard block
 block discarded – undo
210 215
 			if($this->log instanceof \Psr\Log\LoggerInterface) 
211 216
 			{
212 217
 				$this->log->info('Account keys changed.');
218
+			} elseif($this->log >= LEClient::LOG_STATUS) {
219
+				LEFunctions::log('Account keys changed.', 'function changeAccountKey');
213 220
 			}
214
-			elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Account keys changed.', 'function changeAccountKey');
215 221
 			return true;
216
-		}
217
-		else
222
+		} else
218 223
 		{
219 224
 			return false;
220 225
 		}
@@ -235,12 +240,12 @@  discard block
 block discarded – undo
235 240
 			if($this->log instanceof \Psr\Log\LoggerInterface) 
236 241
 			{
237 242
 				$this->log->info('Account deactivated.');
243
+			} elseif($this->log >= LEClient::LOG_STATUS) {
244
+				LEFunctions::log('Account deactivated.', 'function deactivateAccount');
238 245
 			}
239
-			elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Account deactivated.', 'function deactivateAccount');
240 246
 			
241 247
 			return true;
242
-		}
243
-		else
248
+		} else
244 249
 		{
245 250
 			return false;
246 251
 		}
Please login to merge, or discard this patch.
src/LEAuthorization.php 3 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -49,13 +49,13 @@  discard block
 block discarded – undo
49 49
 
50 50
 	private $log;
51 51
 
52
-    /**
53
-     * Initiates the LetsEncrypt Authorization class. Child of a LetsEncrypt Order instance.
54
-     *
55
-     * @param LEConnector	$connector			The LetsEncrypt Connector instance to use for HTTP requests.
56
-     * @param int 			$log 				The level of logging. Defaults to no logging. LOG_OFF, LOG_STATUS, LOG_DEBUG accepted.
57
-     * @param string 		$authorizationURL 	The URL of the authorization, given by a LetsEncrypt order request.
58
-     */
52
+	/**
53
+	 * Initiates the LetsEncrypt Authorization class. Child of a LetsEncrypt Order instance.
54
+	 *
55
+	 * @param LEConnector	$connector			The LetsEncrypt Connector instance to use for HTTP requests.
56
+	 * @param int 			$log 				The level of logging. Defaults to no logging. LOG_OFF, LOG_STATUS, LOG_DEBUG accepted.
57
+	 * @param string 		$authorizationURL 	The URL of the authorization, given by a LetsEncrypt order request.
58
+	 */
59 59
 	public function __construct($connector, $log, $authorizationURL)
60 60
 	{
61 61
 		$this->connector = $connector;
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
 		}
82 82
 	}
83 83
 
84
-    /**
85
-     * Updates the data associated with the current LetsEncrypt Authorization instance.
86
-     */
84
+	/**
85
+	 * Updates the data associated with the current LetsEncrypt Authorization instance.
86
+	 */
87 87
 
88 88
 	public function updateData()
89 89
 	{
@@ -106,14 +106,14 @@  discard block
 block discarded – undo
106 106
 		}
107 107
 	}
108 108
 
109
-    /**
110
-     * Gets the challenge of the given $type for this LetsEncrypt Authorization instance. Throws a Runtime Exception if the given $type is not found in this
109
+	/**
110
+	 * Gets the challenge of the given $type for this LetsEncrypt Authorization instance. Throws a Runtime Exception if the given $type is not found in this
111 111
 	 * LetsEncrypt Authorization instance.
112
-     *
113
-     * @param int	$type 	The type of verification. Supporting LEOrder::CHALLENGE_TYPE_HTTP and LEOrder::CHALLENGE_TYPE_DNS.
114
-     *
115
-     * @return array	Returns an array with the challenge of the requested $type.
116
-     */
112
+	 *
113
+	 * @param int	$type 	The type of verification. Supporting LEOrder::CHALLENGE_TYPE_HTTP and LEOrder::CHALLENGE_TYPE_DNS.
114
+	 *
115
+	 * @return array	Returns an array with the challenge of the requested $type.
116
+	 */
117 117
 	public function getChallenge($type)
118 118
 	{
119 119
 		foreach($this->challenges as $challenge)
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 
65 65
 		$sign = $this->connector->signRequestKid('', $this->connector->accountURL, $this->authorizationURL);
66 66
 		$post = $this->connector->post($this->authorizationURL, $sign);
67
-		if($post['status'] === 200)
67
+		if ($post['status'] === 200)
68 68
 		{
69 69
 			$this->identifier = $post['body']['identifier'];
70 70
 			$this->status = $post['body']['status'];
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
 		}
74 74
 		else
75 75
 		{
76
-			if($this->log instanceof \Psr\Log\LoggerInterface) 
76
+			if ($this->log instanceof \Psr\Log\LoggerInterface) 
77 77
 			{
78 78
 				$this->log->info('Cannot find authorization \'' . $authorizationURL . '\'.');
79 79
 			}
80
-			elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Cannot find authorization \'' . $authorizationURL . '\'.', 'function LEAuthorization __construct');
80
+			elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Cannot find authorization \'' . $authorizationURL . '\'.', 'function LEAuthorization __construct');
81 81
 		}
82 82
 	}
83 83
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	{
90 90
 		$sign = $this->connector->signRequestKid('', $this->connector->accountURL, $this->authorizationURL);
91 91
 		$post = $this->connector->post($this->authorizationURL, $sign);
92
-		if($post['status'] === 200)
92
+		if ($post['status'] === 200)
93 93
 		{
94 94
 			$this->identifier = $post['body']['identifier'];
95 95
 			$this->status = $post['body']['status'];
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 		}
99 99
 		else
100 100
 		{
101
-			if($this->log instanceof \Psr\Log\LoggerInterface) 
101
+			if ($this->log instanceof \Psr\Log\LoggerInterface) 
102 102
 			{
103 103
 				$this->log->info('Cannot find authorization \'' . $this->authorizationURL . '\'.');
104 104
 			}
105
-			elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Cannot find authorization \'' . $this->authorizationURL . '\'.', 'function updateData');
105
+			elseif ($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Cannot find authorization \'' . $this->authorizationURL . '\'.', 'function updateData');
106 106
 		}
107 107
 	}
108 108
 
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
      */
117 117
 	public function getChallenge($type)
118 118
 	{
119
-		foreach($this->challenges as $challenge)
119
+		foreach ($this->challenges as $challenge)
120 120
 		{
121
-			if($challenge['type'] == $type) return $challenge;
121
+			if ($challenge['type'] == $type) return $challenge;
122 122
 		}
123 123
 		throw LEAuthorizationException::NoChallengeFoundException($type, $this->identifier['value']);
124 124
 	}
Please login to merge, or discard this patch.
Braces   +9 added lines, -7 removed lines patch added patch discarded remove patch
@@ -70,14 +70,14 @@  discard block
 block discarded – undo
70 70
 			$this->status = $post['body']['status'];
71 71
 			$this->expires = $post['body']['expires'];
72 72
 			$this->challenges = $post['body']['challenges'];
73
-		}
74
-		else
73
+		} else
75 74
 		{
76 75
 			if($this->log instanceof \Psr\Log\LoggerInterface) 
77 76
 			{
78 77
 				$this->log->info('Cannot find authorization \'' . $authorizationURL . '\'.');
78
+			} elseif($this->log >= LEClient::LOG_STATUS) {
79
+				LEFunctions::log('Cannot find authorization \'' . $authorizationURL . '\'.', 'function LEAuthorization __construct');
79 80
 			}
80
-			elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Cannot find authorization \'' . $authorizationURL . '\'.', 'function LEAuthorization __construct');
81 81
 		}
82 82
 	}
83 83
 
@@ -95,14 +95,14 @@  discard block
 block discarded – undo
95 95
 			$this->status = $post['body']['status'];
96 96
 			$this->expires = $post['body']['expires'];
97 97
 			$this->challenges = $post['body']['challenges'];
98
-		}
99
-		else
98
+		} else
100 99
 		{
101 100
 			if($this->log instanceof \Psr\Log\LoggerInterface) 
102 101
 			{
103 102
 				$this->log->info('Cannot find authorization \'' . $this->authorizationURL . '\'.');
103
+			} elseif($this->log >= LEClient::LOG_STATUS) {
104
+				LEFunctions::log('Cannot find authorization \'' . $this->authorizationURL . '\'.', 'function updateData');
104 105
 			}
105
-			elseif($this->log >= LEClient::LOG_STATUS) LEFunctions::log('Cannot find authorization \'' . $this->authorizationURL . '\'.', 'function updateData');
106 106
 		}
107 107
 	}
108 108
 
@@ -118,7 +118,9 @@  discard block
 block discarded – undo
118 118
 	{
119 119
 		foreach($this->challenges as $challenge)
120 120
 		{
121
-			if($challenge['type'] == $type) return $challenge;
121
+			if($challenge['type'] == $type) {
122
+				return $challenge;
123
+			}
122 124
 		}
123 125
 		throw LEAuthorizationException::NoChallengeFoundException($type, $this->identifier['value']);
124 126
 	}
Please login to merge, or discard this patch.
src/Exceptions/LEOrderException.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -38,10 +38,10 @@
 block discarded – undo
38 38
 class LEOrderException extends LEException
39 39
 {
40 40
 	public const INVALIDKEYTYPEEXCEPTION 		= 0x31;
41
-	public const INVALIDORDERSTATUSEXCEPTION 	= 0x32;
42
-	public const CREATEFAILEDEXCEPTION 			= 0x33;
41
+	public const INVALIDORDERSTATUSEXCEPTION = 0x32;
42
+	public const CREATEFAILEDEXCEPTION = 0x33;
43 43
 	public const INVALIDARGUMENTEXCEPTION		= 0x34;
44
-	public const INVALIDCONFIGURATIONEXCEPTION	= 0x35;	
44
+	public const INVALIDCONFIGURATIONEXCEPTION = 0x35;	
45 45
 	
46 46
 	public static function InvalidKeyTypeException(string $keyType)
47 47
 	{
Please login to merge, or discard this patch.
src/Exceptions/LEClientException.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,8 +37,8 @@
 block discarded – undo
37 37
  */
38 38
 class LEClientException extends LEException
39 39
 {
40
-	public const INVALIDARGUMENTEXCEPTION 	= 0x01;
41
-	public const INVALIDDIRECTORYEXCEPTION 	= 0x02;
40
+	public const INVALIDARGUMENTEXCEPTION = 0x01;
41
+	public const INVALIDDIRECTORYEXCEPTION = 0x02;
42 42
 	
43 43
 	public static function InvalidArgumentException(string $message)
44 44
 	{
Please login to merge, or discard this patch.
src/Exceptions/LEFunctionsException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
 {
40 40
 	public const INVALIDARGUMENTEXCEPTION 	= 0x51;
41 41
 	public const GENERATEKEYPAIREXCEPTION 	= 0x52;
42
-	public const PHPVERSIONEXCEPTION 		= 0x53;
42
+	public const PHPVERSIONEXCEPTION = 0x53;
43 43
 	
44 44
 	public static function InvalidArgumentException(string $message)
45 45
 	{
Please login to merge, or discard this patch.
src/Exceptions/LEAccountException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
  */
38 38
 class LEAccountException extends LEException
39 39
 {
40
-	public const ACCOUNTNOTFOUNDEEXCEPTION 	= 0x21;
40
+	public const ACCOUNTNOTFOUNDEEXCEPTION = 0x21;
41 41
 	
42 42
 	public static function AccountNotFoundException()
43 43
 	{
Please login to merge, or discard this patch.
src/Exceptions/LEAuthorizationException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
  */
38 38
 class LEAuthorizationException extends LEException
39 39
 {
40
-	public const NOCHALLENGEFOUNDEEXCEPTION	= 0x41;
40
+	public const NOCHALLENGEFOUNDEEXCEPTION = 0x41;
41 41
 	
42 42
 	public static function NoChallengeFoundException($type, $identifier)
43 43
 	{
Please login to merge, or discard this patch.
src/Exceptions/LEConnectorException.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,11 +37,11 @@
 block discarded – undo
37 37
  */
38 38
 class LEConnectorException extends LEException
39 39
 {
40
-	public const NONEWNONCEEXCEPTION 			= 0x11;
40
+	public const NONEWNONCEEXCEPTION = 0x11;
41 41
 	public const ACCOUNTDEACTIVATEDEXCEPTION 	= 0x12;
42 42
 	public const METHODNOTSUPPORTEDEXCEPTION 	= 0x13;
43
-	public const CURLERROREXCEPTION 			= 0x14;
44
-	public const INVALIDRESPONSEEXCEPTION 		= 0x15;
43
+	public const CURLERROREXCEPTION = 0x14;
44
+	public const INVALIDRESPONSEEXCEPTION = 0x15;
45 45
 	
46 46
 	public static function NoNewNonceException()
47 47
 	{
Please login to merge, or discard this patch.