Completed
Pull Request — master (#2)
by John
13:19
created
examples/exampleDNSInit.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace Elphin\LEClient;
3 3
 
4
-require_once(__DIR__.'/../vendor/autoload.php');
4
+require_once(__DIR__ . '/../vendor/autoload.php');
5 5
 
6 6
 //Sets the maximum execution time to two minutes, to be sure.
7 7
 ini_set('max_execution_time', 120);
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
 $email = ['[email protected]'];
17 17
 $basename = 'le.dixo.net';
18
-$domains=['le.dixo.net'];
18
+$domains = ['le.dixo.net'];
19 19
 
20 20
 $logger = new DiagnosticLogger;
21 21
 
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
     }
47 47
 }
48 48
 catch (\Exception $e) {
49
-    echo $e->getMessage()."\n";
50
-    echo $e->getTraceAsString()."\n";
49
+    echo $e->getMessage() . "\n";
50
+    echo $e->getTraceAsString() . "\n";
51 51
 
52 52
     echo "\nDiagnostic logs\n";
53 53
     $logger->dumpConsole();
Please login to merge, or discard this patch.
examples/exampleDNSFinish.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace Elphin\LEClient;
3 3
 
4
-require_once(__DIR__.'/../vendor/autoload.php');
4
+require_once(__DIR__ . '/../vendor/autoload.php');
5 5
 
6 6
 //Sets the maximum execution time to two minutes, to be sure.
7 7
 ini_set('max_execution_time', 120);
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
 $email = ['[email protected]'];
17 17
 $basename = 'le.dixo.net';
18
-$domains=['le.dixo.net'];
18
+$domains = ['le.dixo.net'];
19 19
 
20 20
 $logger = new DiagnosticLogger;
21 21
 
@@ -26,14 +26,14 @@  discard block
 block discarded – undo
26 26
 // in the array (argument 2) will be on the certificate.
27 27
 $order = $client->getOrCreateOrder($basename, $domains);
28 28
 // Check whether there are any authorizations pending. If that is the case, try to verify the pending authorizations.
29
-if(!$order->allAuthorizationsValid())
29
+if (!$order->allAuthorizationsValid())
30 30
 {
31 31
 	// Get the DNS challenges from the pending authorizations.
32 32
 	$pending = $order->getPendingAuthorizations(LEOrder::CHALLENGE_TYPE_DNS);
33 33
 	// Walk the list of pending authorization DNS challenges.
34
-	if(!empty($pending))
34
+	if (!empty($pending))
35 35
 	{
36
-		foreach($pending as $challenge)
36
+		foreach ($pending as $challenge)
37 37
 		{
38 38
 			// Let LetsEncrypt verify this challenge, which should have been fulfilled in exampleDNSStart.php.
39 39
 			$order->verifyPendingOrderAuthorization($challenge['identifier'], LEOrder::CHALLENGE_TYPE_DNS);
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
 	}
42 42
 }
43 43
 // Check once more whether all authorizations are valid before we can finalize the order.
44
-if($order->allAuthorizationsValid())
44
+if ($order->allAuthorizationsValid())
45 45
 {
46 46
 	// Finalize the order first, if that is not yet done.
47
-	if(!$order->isFinalized()) $order->finalizeOrder();
47
+	if (!$order->isFinalized()) $order->finalizeOrder();
48 48
 	// Check whether the order has been finalized before we can get the certificate. If finalized, get the certificate.
49
-	if($order->isFinalized()) $order->getCertificate();
49
+	if ($order->isFinalized()) $order->getCertificate();
50 50
 
51 51
 	//finally, here's how we revoke
52 52
     //echo "REVOKING...\n";
Please login to merge, or discard this patch.
examples/exampleHTTP.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace Elphin\LEClient;
3 3
 
4
-require_once(__DIR__.'/../vendor/autoload.php');
4
+require_once(__DIR__ . '/../vendor/autoload.php');
5 5
 
6 6
 //Sets the maximum execution time to two minutes, to be sure.
7 7
 ini_set('max_execution_time', 120);
@@ -22,20 +22,20 @@  discard block
 block discarded – undo
22 22
 // domains in the array (argument 2) will be on the certificate.
23 23
 $order = $client->getOrCreateOrder($basename, $domains);
24 24
 // Check whether there are any authorizations pending. If that is the case, try to verify the pending authorizations.
25
-if(!$order->allAuthorizationsValid())
25
+if (!$order->allAuthorizationsValid())
26 26
 {
27 27
 	// Get the HTTP challenges from the pending authorizations.
28 28
 	$pending = $order->getPendingAuthorizations(LEOrder::CHALLENGE_TYPE_HTTP);
29 29
 	// Walk the list of pending authorization HTTP challenges.
30
-	if(!empty($pending))
30
+	if (!empty($pending))
31 31
 	{
32
-		foreach($pending as $challenge)
32
+		foreach ($pending as $challenge)
33 33
 		{
34 34
 			// Define the folder in which to store the challenge. For the purpose of this example, a fictitious path is
35 35
             // set.
36 36
 			$folder = '/path/to/' . $challenge['identifier'] . '/.well-known/acme-challenge/';
37 37
 			// Check if that directory yet exists. If not, create it.
38
-			if(!file_exists($folder)) mkdir($folder, 0777, true);
38
+			if (!file_exists($folder)) mkdir($folder, 0777, true);
39 39
 			// Store the challenge file for this domain.
40 40
 			file_put_contents($folder . $challenge['filename'], $challenge['content']);
41 41
 			// Let LetsEncrypt verify this challenge.
@@ -44,12 +44,12 @@  discard block
 block discarded – undo
44 44
 	}
45 45
 }
46 46
 // Check once more whether all authorizations are valid before we can finalize the order.
47
-if($order->allAuthorizationsValid())
47
+if ($order->allAuthorizationsValid())
48 48
 {
49 49
 	// Finalize the order first, if that is not yet done.
50
-	if(!$order->isFinalized()) $order->finalizeOrder();
50
+	if (!$order->isFinalized()) $order->finalizeOrder();
51 51
 	// Check whether the order has been finalized before we can get the certificate. If finalized, get the certificate.
52
-	if($order->isFinalized()) $order->getCertificate();
52
+	if ($order->isFinalized()) $order->getCertificate();
53 53
 }
54 54
 
55 55
 echo "\nDiagnostic logs\n";
Please login to merge, or discard this patch.
src/LEAccount.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
         $this->log = $log;
46 46
 
47 47
         if (empty($storage->getAccountPublicKey()) || empty($storage->getAccountPrivateKey())) {
48
-            $this->log->notice("No account found for ".implode(',', $email).", attempting to create account");
48
+            $this->log->notice("No account found for " . implode(',', $email) . ", attempting to create account");
49 49
 
50 50
             $accountKey = LEFunctions::RSAgenerateKeys();
51 51
             $storage->setAccountPublicKey($accountKey['public']);
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      */
71 71
     private function createLEAccount($email)
72 72
     {
73
-        $contact = array_map(function ($addr) {
73
+        $contact = array_map(function($addr) {
74 74
             return empty($addr) ? '' : (strpos($addr, 'mailto') === false ? 'mailto:' . $addr : $addr);
75 75
         }, $email);
76 76
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
      */
143 143
     public function updateAccount($email)
144 144
     {
145
-        $contact = array_map(function ($addr) {
145
+        $contact = array_map(function($addr) {
146 146
             return empty($addr) ? '' : (strpos($addr, 'mailto') === false ? 'mailto:' . $addr : $addr);
147 147
         }, $email);
148 148
 
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
      */
178 178
     public function changeAccountKeys()
179 179
     {
180
-        $new=LEFunctions::RSAgenerateKeys();
180
+        $new = LEFunctions::RSAgenerateKeys();
181 181
 
182 182
         $privateKey = openssl_pkey_get_private($new['private']);
183 183
         if ($privateKey === false) {
Please login to merge, or discard this patch.
src/FilesystemCertificateStorage.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
     public function __construct($dir = null)
16 16
     {
17
-        $this->dir = $dir ?? getcwd().DIRECTORY_SEPARATOR.'certificates';
17
+        $this->dir = $dir ?? getcwd() . DIRECTORY_SEPARATOR . 'certificates';
18 18
 
19 19
         if (!is_dir($this->dir)) {
20 20
             /** @scrutinizer ignore-unhandled */ @mkdir($this->dir);
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
     private function getDomainKey($domain, $suffix)
61 61
     {
62
-        return str_replace('*', 'wildcard', $domain).'.'.$suffix;
62
+        return str_replace('*', 'wildcard', $domain) . '.' . $suffix;
63 63
     }
64 64
     /**
65 65
      * @inheritdoc
@@ -127,8 +127,8 @@  discard block
 block discarded – undo
127 127
 
128 128
     private function getMetadataFilename($key)
129 129
     {
130
-        $key=str_replace('*', 'wildcard', $key);
131
-        $file=$this->dir.DIRECTORY_SEPARATOR.$key;
130
+        $key = str_replace('*', 'wildcard', $key);
131
+        $file = $this->dir . DIRECTORY_SEPARATOR . $key;
132 132
         return $file;
133 133
     }
134 134
     /**
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      */
137 137
     public function getMetadata($key)
138 138
     {
139
-        $file=$this->getMetadataFilename($key);
139
+        $file = $this->getMetadataFilename($key);
140 140
         if (!file_exists($file)) {
141 141
             return null;
142 142
         }
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
      */
149 149
     public function setMetadata($key, $value)
150 150
     {
151
-        $file=$this->getMetadataFilename($key);
151
+        $file = $this->getMetadataFilename($key);
152 152
         if (is_null($value)) {
153 153
             //nothing to store, ensure file is removed
154 154
             if (file_exists($file)) {
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      */
165 165
     public function hasMetadata($key)
166 166
     {
167
-        $file=$this->getMetadataFilename($key);
167
+        $file = $this->getMetadataFilename($key);
168 168
         return file_exists($file);
169 169
     }
170 170
 }
Please login to merge, or discard this patch.
src/LEConnector.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -154,7 +154,7 @@
 block discarded – undo
154 154
             //4xx/5xx failures are not expected and we throw exceptions for them
155 155
             $msg = "$method $URL failed";
156 156
             if ($e->hasResponse()) {
157
-                $body = (string)$e->getResponse()->getBody();
157
+                $body = (string) $e->getResponse()->getBody();
158 158
                 $json = json_decode($body, true);
159 159
                 if (!empty($json) && isset($json['detail'])) {
160 160
                     $msg .= " ({$json['detail']})";
Please login to merge, or discard this patch.
src/DNSValidator/DNSOverHTTPS.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@
 block discarded – undo
104 104
             'query' => [
105 105
                 'name'               => $name,
106 106
                 'type'               => $type,
107
-                'edns_client_subnet' => '0.0.0.0/0',            //disable geotagged dns results
107
+                'edns_client_subnet' => '0.0.0.0/0', //disable geotagged dns results
108 108
                 'ct'                 => 'application/dns-json', //cloudflare requires this
109 109
             ],
110 110
             'headers' => [
Please login to merge, or discard this patch.
src/DNSValidator/NativeDNS.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
     public function checkChallenge($domain, $requiredDigest) : bool
14 14
     {
15 15
         $hostname = '_acme-challenge.' . str_replace('*.', '', $domain);
16
-        $records =  dns_get_record($hostname, DNS_TXT);
16
+        $records = dns_get_record($hostname, DNS_TXT);
17 17
         foreach ($records as $record) {
18 18
             if ($record['host'] == $hostname && $record['type'] == 'TXT' && $record['txt'] == $requiredDigest) {
19 19
                 return true;
Please login to merge, or discard this patch.
src/Sleep.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
  */
11 11
 class Sleep
12 12
 {
13
-    public function for($seconds)
13
+    public function for ($seconds)
14 14
     {
15 15
         sleep($seconds);
16 16
     }
Please login to merge, or discard this patch.