Passed
Branch master (c73d10)
by Stefan
02:51 queued 55s
created
PNTestServer.php 2 patches
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -9,112 +9,112 @@
 block discarded – undo
9 9
 use SKien\PNServer\PNPayload;
10 10
 use SKien\PNServer\PNServer;
11 11
 
12
-	// check, if PHP version is sufficient and all required extensions are installed
13
-	$bExit = false;
14
-	if (version_compare(phpversion(), '7.1', '<')) {
15
-		trigger_error('At least PHP Version 7.1 is required (current Version is ' . phpversion() . ')!', E_USER_WARNING);
16
-		$bExit = true;
17
-	}
18
-	$aExt = array('curl', 'gmp', 'mbstring', 'openssl', 'bcmath');
19
-	foreach ($aExt as $strExt) {
20
-		if (!extension_loaded($strExt)) {
21
-			trigger_error('Extension ' . $strExt . ' must be installed!', E_USER_WARNING);
22
-			$bExit = true;
23
-		}
24
-	}
25
-	if ($bExit) {
26
-		exit();
27
-	}
12
+    // check, if PHP version is sufficient and all required extensions are installed
13
+    $bExit = false;
14
+    if (version_compare(phpversion(), '7.1', '<')) {
15
+        trigger_error('At least PHP Version 7.1 is required (current Version is ' . phpversion() . ')!', E_USER_WARNING);
16
+        $bExit = true;
17
+    }
18
+    $aExt = array('curl', 'gmp', 'mbstring', 'openssl', 'bcmath');
19
+    foreach ($aExt as $strExt) {
20
+        if (!extension_loaded($strExt)) {
21
+            trigger_error('Extension ' . $strExt . ' must be installed!', E_USER_WARNING);
22
+            $bExit = true;
23
+        }
24
+    }
25
+    if ($bExit) {
26
+        exit();
27
+    }
28 28
 
29
-	// for test use SQLite database - will be cretaed at first instantiation
30
-	$oDP = new PNDataProviderSQLite();
29
+    // for test use SQLite database - will be cretaed at first instantiation
30
+    $oDP = new PNDataProviderSQLite();
31 31
 	
32
-	// or may use any MySQL database
33
-	// $oDP = new PNDataProviderMySQL('localhost', 'username', 'password', 'db-name');
32
+    // or may use any MySQL database
33
+    // $oDP = new PNDataProviderMySQL('localhost', 'username', 'password', 'db-name');
34 34
 	
35
-	if (!$oDP->isConnected()) {
36
-	    echo $oDP->getError();
37
-		exit();
38
-	}
35
+    if (!$oDP->isConnected()) {
36
+        echo $oDP->getError();
37
+        exit();
38
+    }
39 39
 
40
-	// just add expired (unsubscribed) subscription to demonstrate response of
41
-	// push service and the auto-remove option
42
-	if (!$oDP->saveSubscription(
43
-			'{'
44
-			.'	"endpoint": "https://fcm.googleapis.com/fcm/send/f8PIq7EL6xI:APA91bFgD2qA0Goo_6sWgWVDKclh5Sm1Gf1BtYZw3rePs_GHqmC9l2N92I4QhLQtPmyB18HYYseFHLhvMbpq-oGz2Jtt8AVExmNU9R3K9Z-Gaiq6rQxig1WT4ND_5PSXTjuth-GoGggt",'
45
-			.'	"expirationTime": "1589291569000",'
46
-			.'	"keys": {'
47
-			.'	"p256dh": "BEQrfuNX-ZrXPf0Mm-IdVMO1LMpu5N3ifgcyeUD2nYwuUhRUDmn_wVOM3eQyYux5vW2B8-TyTYco4-bFKKR02IA",'
48
-			.'	"auth": "jOfywakW_srfHhMF-NiZ3Q"'
49
-			.'	}'
50
-			.'}'
51
-	    )) {
52
-	    echo $oDP->getError();
53
-	    exit();
54
-	}
40
+    // just add expired (unsubscribed) subscription to demonstrate response of
41
+    // push service and the auto-remove option
42
+    if (!$oDP->saveSubscription(
43
+            '{'
44
+            .'	"endpoint": "https://fcm.googleapis.com/fcm/send/f8PIq7EL6xI:APA91bFgD2qA0Goo_6sWgWVDKclh5Sm1Gf1BtYZw3rePs_GHqmC9l2N92I4QhLQtPmyB18HYYseFHLhvMbpq-oGz2Jtt8AVExmNU9R3K9Z-Gaiq6rQxig1WT4ND_5PSXTjuth-GoGggt",'
45
+            .'	"expirationTime": "1589291569000",'
46
+            .'	"keys": {'
47
+            .'	"p256dh": "BEQrfuNX-ZrXPf0Mm-IdVMO1LMpu5N3ifgcyeUD2nYwuUhRUDmn_wVOM3eQyYux5vW2B8-TyTYco4-bFKKR02IA",'
48
+            .'	"auth": "jOfywakW_srfHhMF-NiZ3Q"'
49
+            .'	}'
50
+            .'}'
51
+        )) {
52
+        echo $oDP->getError();
53
+        exit();
54
+    }
55 55
 	
56
-	echo 'Count of subscriptions: ' . $oDP->count() . '<br/><br/>' . PHP_EOL;
57
-	if ($oDP->init()) {
58
-		while (($strJsonSub = $oDP->fetch()) !== false) {
59
-			echo 'UA: ' . $oDP->getColumn(PNDataProvider::COL_USERAGENT);
60
-			echo ' (Lastupdated: ' . date('Y-m-d H:i:s', $oDP->getColumn(PNDataProvider::COL_LASTUPDATED)) . ')<br/>' . PHP_EOL;			
61
-			$strPrintable = json_encode(json_decode($strJsonSub), JSON_PRETTY_PRINT);
62
-			$strPrintable = str_replace("\n", '<br/>', $strPrintable);
63
-			$strPrintable = str_replace(" ", '&nbsp;', $strPrintable);
64
-			echo '<span style="font-size: 10pt; font-family: courier; overflow:scroll; white-space: nowrap">' . $strPrintable . '</span><br/><br/>' . PHP_EOL;			
65
-		}
66
-	} else {
67
-    	echo $oDP->getError();
68
-    	exit();
69
-	}
56
+    echo 'Count of subscriptions: ' . $oDP->count() . '<br/><br/>' . PHP_EOL;
57
+    if ($oDP->init()) {
58
+        while (($strJsonSub = $oDP->fetch()) !== false) {
59
+            echo 'UA: ' . $oDP->getColumn(PNDataProvider::COL_USERAGENT);
60
+            echo ' (Lastupdated: ' . date('Y-m-d H:i:s', $oDP->getColumn(PNDataProvider::COL_LASTUPDATED)) . ')<br/>' . PHP_EOL;			
61
+            $strPrintable = json_encode(json_decode($strJsonSub), JSON_PRETTY_PRINT);
62
+            $strPrintable = str_replace("\n", '<br/>', $strPrintable);
63
+            $strPrintable = str_replace(" ", '&nbsp;', $strPrintable);
64
+            echo '<span style="font-size: 10pt; font-family: courier; overflow:scroll; white-space: nowrap">' . $strPrintable . '</span><br/><br/>' . PHP_EOL;			
65
+        }
66
+    } else {
67
+        echo $oDP->getError();
68
+        exit();
69
+    }
70 70
 	
71
-	// the server to handle all
72
-	$oServer = new PNServer($oDP);
71
+    // the server to handle all
72
+    $oServer = new PNServer($oDP);
73 73
 
74
-	// set the VAPID key
75
-	/*
74
+    // set the VAPID key
75
+    /*
76 76
 	$oVapid = new PNVapid(
77 77
 			"mailto:[email protected]",
78 78
 			"the-generated-public-key",
79 79
 			"the-generated-private-key"
80 80
 	   );
81 81
 	*/
82
-	$oVapid = new PNVapid(
83
-	       "mailto:[email protected]",
84
-	       "BDtOCcUUTYvuUzx9ktgYs3mB6tQCjFLNfOkuiaIi_2LNosLbHQY6P91eMzQ8opTDLK_PjJHsjMSiJ-MUOeSjV8E",
85
-	       "juLDCbPNbObvn-89_o0SEbnBZLMWxlVEjGypyxHEh2M"
86
-	   );
82
+    $oVapid = new PNVapid(
83
+            "mailto:[email protected]",
84
+            "BDtOCcUUTYvuUzx9ktgYs3mB6tQCjFLNfOkuiaIi_2LNosLbHQY6P91eMzQ8opTDLK_PjJHsjMSiJ-MUOeSjV8E",
85
+            "juLDCbPNbObvn-89_o0SEbnBZLMWxlVEjGypyxHEh2M"
86
+        );
87 87
 	        
88
-	$oServer->setVapid($oVapid);
88
+    $oServer->setVapid($oVapid);
89 89
 	
90
-	// create payload
91
-	// - we don't set a title - so service worker uses default
92
-	// - URL to icon can be
93
-	//    * relative to the origin location of the service worker
94
-	//    * absolute from the homepage (begining with a '/')
95
-	//    * complete URL (beginning with https://) 
96
-	$oPayload = new PNPayload('', "...first text to display.", './elephpant.png');
97
-	// set tag to group the notifications but always show the popup 
98
-	$oPayload->setTag('news', true);
99
-	// and lead the user to thr page of your choice
100
-	$oPayload->setURL('/where-to-go.php');
90
+    // create payload
91
+    // - we don't set a title - so service worker uses default
92
+    // - URL to icon can be
93
+    //    * relative to the origin location of the service worker
94
+    //    * absolute from the homepage (begining with a '/')
95
+    //    * complete URL (beginning with https://) 
96
+    $oPayload = new PNPayload('', "...first text to display.", './elephpant.png');
97
+    // set tag to group the notifications but always show the popup 
98
+    $oPayload->setTag('news', true);
99
+    // and lead the user to thr page of your choice
100
+    $oPayload->setURL('/where-to-go.php');
101 101
 	
102
-	$oServer->setPayload($oPayload);
102
+    $oServer->setPayload($oPayload);
103 103
 
104
-	// load subscriptions from database (incluing the expired one created above...) 
105
-	if (!$oServer->loadSubscriptions()) {
106
-	    echo $oDP->getError();
107
-	    exit();
108
-	}
104
+    // load subscriptions from database (incluing the expired one created above...) 
105
+    if (!$oServer->loadSubscriptions()) {
106
+        echo $oDP->getError();
107
+        exit();
108
+    }
109 109
 	
110
-	// ... and finally push !
111
-	if (!$oServer->push()) {
112
-		echo '<h2>' . $oServer->getError() . '</h2>' . PHP_EOL;
113
-	} else {
114
-		$aLog = $oServer->getLog();
115
-		echo '<h2>Push - Log:</h2>' . PHP_EOL;
116
-		foreach ($aLog as $strEndpoint => $aMsg ) {
117
-			echo '<h3>' . PNSubscription::getOrigin($strEndpoint) . '</h3>' . PHP_EOL;
118
-			echo $aMsg['msg'] . '<br/>resonse code: ' . $aMsg['curl_response_code']  . ' (' . $aMsg['curl_response'] . ')';	
119
-		}
120
-	}
110
+    // ... and finally push !
111
+    if (!$oServer->push()) {
112
+        echo '<h2>' . $oServer->getError() . '</h2>' . PHP_EOL;
113
+    } else {
114
+        $aLog = $oServer->getLog();
115
+        echo '<h2>Push - Log:</h2>' . PHP_EOL;
116
+        foreach ($aLog as $strEndpoint => $aMsg ) {
117
+            echo '<h3>' . PNSubscription::getOrigin($strEndpoint) . '</h3>' . PHP_EOL;
118
+            echo $aMsg['msg'] . '<br/>resonse code: ' . $aMsg['curl_response_code']  . ' (' . $aMsg['curl_response'] . ')';	
119
+        }
120
+    }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -113,8 +113,8 @@
 block discarded – undo
113 113
 	} else {
114 114
 		$aLog = $oServer->getLog();
115 115
 		echo '<h2>Push - Log:</h2>' . PHP_EOL;
116
-		foreach ($aLog as $strEndpoint => $aMsg ) {
116
+		foreach ($aLog as $strEndpoint => $aMsg) {
117 117
 			echo '<h3>' . PNSubscription::getOrigin($strEndpoint) . '</h3>' . PHP_EOL;
118
-			echo $aMsg['msg'] . '<br/>resonse code: ' . $aMsg['curl_response_code']  . ' (' . $aMsg['curl_response'] . ')';	
118
+			echo $aMsg['msg'] . '<br/>resonse code: ' . $aMsg['curl_response_code'] . ' (' . $aMsg['curl_response'] . ')';	
119 119
 		}
120 120
 	}
Please login to merge, or discard this patch.
PNSubscriber.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
 $result = array();
7 7
 // only serve POST request containing valid json data
8 8
 if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
9
-	if (isset($_SERVER['CONTENT_TYPE'])	&& trim(strtolower($_SERVER['CONTENT_TYPE']) == 'application/json')) {
9
+	if (isset($_SERVER['CONTENT_TYPE']) && trim(strtolower($_SERVER['CONTENT_TYPE']) == 'application/json')) {
10 10
 		// get posted json data
11 11
 		if (($strJSON = trim(file_get_contents('php://input'))) === false) {
12 12
 			$result['msg'] = 'invalid JSON data!';
Please login to merge, or discard this patch.
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -33,26 +33,26 @@
 block discarded – undo
33 33
 $result = array();
34 34
 // only serve POST request containing valid json data
35 35
 if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
36
-	if (isset($_SERVER['CONTENT_TYPE'])	&& trim(strtolower($_SERVER['CONTENT_TYPE']) == 'application/json')) {
37
-		// get posted json data
38
-		if (($strJSON = trim(file_get_contents('php://input'))) === false) {
39
-			$result['msg'] = 'invalid JSON data!';
40
-		} else {
41
-			$oDP = new PNDataProviderSQLite();
42
-			if ($oDP->saveSubscription($strJSON) !== false) {
43
-				$result['msg'] = 'subscription saved on server!';
44
-				if ($bSendWelcome) {
45
-				    sendWelcome(PNSubscription::fromJSON($strJSON));
46
-				}
47
-			} else {
48
-				$result['msg'] = 'error saving subscription!';
49
-			}
50
-		}
51
-	} else {
52
-		$result['msg'] = 'invalid content type!';
53
-	}
36
+    if (isset($_SERVER['CONTENT_TYPE'])	&& trim(strtolower($_SERVER['CONTENT_TYPE']) == 'application/json')) {
37
+        // get posted json data
38
+        if (($strJSON = trim(file_get_contents('php://input'))) === false) {
39
+            $result['msg'] = 'invalid JSON data!';
40
+        } else {
41
+            $oDP = new PNDataProviderSQLite();
42
+            if ($oDP->saveSubscription($strJSON) !== false) {
43
+                $result['msg'] = 'subscription saved on server!';
44
+                if ($bSendWelcome) {
45
+                    sendWelcome(PNSubscription::fromJSON($strJSON));
46
+                }
47
+            } else {
48
+                $result['msg'] = 'error saving subscription!';
49
+            }
50
+        }
51
+    } else {
52
+        $result['msg'] = 'invalid content type!';
53
+    }
54 54
 } else {
55
-	$result['msg'] = 'no post request!';
55
+    $result['msg'] = 'no post request!';
56 56
 }
57 57
 // let the service-worker know the result
58 58
 echo json_encode($result);
Please login to merge, or discard this patch.
SKien/PNServer/PNEncryption.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types = 1);
2
+declare(strict_types=1);
3 3
 
4 4
 namespace SKien\PNServer;
5 5
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      * @param string $strSubscrAuth     subscription authenthication code
59 59
      * @param string $strEncoding       encoding (default: 'aesgcm')
60 60
      */
61
-    public function __construct(string $strSubscrKey, string $strSubscrAuth, string $strEncoding='aesgcm') 
61
+    public function __construct(string $strSubscrKey, string $strSubscrAuth, string $strEncoding = 'aesgcm') 
62 62
     {
63 63
         $this->strSubscrKey = self::decodeBase64URL($strSubscrKey);
64 64
         $this->strSubscrAuth = self::decodeBase64URL($strSubscrAuth);
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      * @param array $aHeaders   existing headers to merge with
151 151
      * @return array
152 152
      */
153
-    public function getHeaders(?array $aHeaders=null) : array 
153
+    public function getHeaders(?array $aHeaders = null) : array 
154 154
     {
155 155
         if (!$aHeaders) {
156 156
             $aHeaders = array();
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
      * @param int $iMaxLengthToPad
332 332
      * @return string
333 333
      */
334
-    private function padPayload(string $strPayload, int $iMaxLengthToPad=0) : string
334
+    private function padPayload(string $strPayload, int $iMaxLengthToPad = 0) : string
335 335
     {
336 336
         $iLen = mb_strlen($strPayload, '8bit');
337 337
         $iPad = $iMaxLengthToPad ? $iMaxLengthToPad - $iLen : 0;
@@ -370,6 +370,6 @@  discard block
 block discarded – undo
370 370
         $prk = hash_hmac('sha256', $ikm, $salt, true);
371 371
     
372 372
         // expand
373
-        return mb_substr(hash_hmac('sha256', $info.chr(1), $prk, true), 0, $length, '8bit');
373
+        return mb_substr(hash_hmac('sha256', $info . chr(1), $prk, true), 0, $length, '8bit');
374 374
     }
375 375
 }
Please login to merge, or discard this patch.
SKien/PNServer/PNPayload.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types = 1);
2
+declare(strict_types=1);
3 3
 
4 4
 namespace SKien\PNServer;
5 5
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      * @param string $strText A string representing an extra content to display within the notification.
43 43
      * @param string $strIcon containing the URL of an image to be used as an icon by the notification.
44 44
      */
45
-    public function __construct(string $strTitle, ?string $strText=null, ?string $strIcon=null) 
45
+    public function __construct(string $strTitle, ?string $strText = null, ?string $strIcon = null) 
46 46
     {
47 47
         $this->aPayload = array(
48 48
                 'title' => $strTitle,
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     public function setURL(string $strURL) : void
61 61
     {
62 62
         if (is_array($this->aPayload) && isset($this->aPayload['opt']) && is_array($this->aPayload['opt'])) {
63
-            if (!isset($this->aPayload['opt']['data']) || !is_array($this->aPayload['opt']['data'] )) {
63
+            if (!isset($this->aPayload['opt']['data']) || !is_array($this->aPayload['opt']['data'])) {
64 64
                 $this->aPayload['opt']['data'] = array();
65 65
             }
66 66
             $this->aPayload['opt']['data']['url'] = $strURL;
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
      * @param string $strTag
77 77
      * @param bool $bReNotify
78 78
      */
79
-    public function setTag(string $strTag, bool $bReNotify=false) : void
79
+    public function setTag(string $strTag, bool $bReNotify = false) : void
80 80
     {
81 81
         if (is_array($this->aPayload) && isset($this->aPayload['opt']) && is_array($this->aPayload['opt'])) {
82 82
             $this->aPayload['opt']['tag'] = $strTag;
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
      * @param string $strIcon       containing the URL of an icon to display with the action.
127 127
      * @param string $strCustom     custom info - not part of the showNotification()- Options!
128 128
      */
129
-    public function addAction(string $strAction, string $strTitle, ?string $strIcon=null, string $strCustom='') : void
129
+    public function addAction(string $strAction, string $strTitle, ?string $strIcon = null, string $strCustom = '') : void
130 130
     {
131 131
         if (is_array($this->aPayload) && isset($this->aPayload['opt']) && is_array($this->aPayload['opt'])) {
132
-            if (!isset($this->aPayload['opt']['actions']) || !is_array($this->aPayload['opt']['actions'] )) {
132
+            if (!isset($this->aPayload['opt']['actions']) || !is_array($this->aPayload['opt']['actions'])) {
133 133
                 $this->aPayload['opt']['actions'] = array();
134 134
             }
135 135
             $this->aPayload['opt']['actions'][] = array('action' => $strAction, 'title' => $strTitle, 'icon' => $strIcon, 'custom' => $strCustom);
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
                 $iTimestamp = strtotime($timestamp);
157 157
             }
158 158
             // timestamp in milliseconds!
159
-            $this->aPayload['opt']['timestamp'] = bcmul((string)$iTimestamp, '1000');
159
+            $this->aPayload['opt']['timestamp'] = bcmul((string) $iTimestamp, '1000');
160 160
         }
161 161
     }
162 162
     
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
      * 
169 169
      * @param bool $bSet
170 170
      */
171
-    public function requireInteraction(bool $bSet=true) : void
171
+    public function requireInteraction(bool $bSet = true) : void
172 172
     {
173 173
         if (is_array($this->aPayload) && isset($this->aPayload['opt']) && is_array($this->aPayload['opt'])) {
174 174
             $this->aPayload['opt']['requireInteraction'] = $bSet;
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
      * If this 'mute' function is activated, a previously set vibration is reset to prevent a TypeError exception.
181 181
      * @param bool $bSet
182 182
      */
183
-    public function setSilent(bool $bSet=true) : void
183
+    public function setSilent(bool $bSet = true) : void
184 184
     {
185 185
         if (is_array($this->aPayload) && isset($this->aPayload['opt']) && is_array($this->aPayload['opt'])) {
186 186
             $this->aPayload['opt']['silent'] = $bSet;
Please login to merge, or discard this patch.
SKien/PNServer/PNSubscription.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types = 1);
2
+declare(strict_types=1);
3 3
 
4 4
 namespace SKien\PNServer;
5 5
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      * @param int $timeExpiration
40 40
      * @param string $strEncoding
41 41
      */
42
-    public function __construct(string $strEndpoint, string $strPublicKey, string $strAuth, int $timeExpiration=0, string $strEncoding='aesgcm') 
42
+    public function __construct(string $strEndpoint, string $strPublicKey, string $strAuth, int $timeExpiration = 0, string $strEncoding = 'aesgcm') 
43 43
     {
44 44
         $this->strEndpoint = $strEndpoint;
45 45
         $this->strPublicKey = $strPublicKey;
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
                     isset($this->strEndpoint) && strlen($this->strEndpoint) > 0 &&
91 91
                     isset($this->strPublicKey) && strlen($this->strPublicKey) > 0 &&
92 92
                     isset($this->strAuth) && strlen($this->strAuth) > 0 &&
93
-                    ($this->strEncoding == 'aesgcm'|| $this->strEncoding == 'aes128gcm') 
93
+                    ($this->strEncoding == 'aesgcm' || $this->strEncoding == 'aes128gcm') 
94 94
                 );
95 95
         }
96 96
         return $bValid;
Please login to merge, or discard this patch.
SKien/PNServer/PNServerHelper.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types = 1);
2
+declare(strict_types=1);
3 3
 
4 4
 namespace SKien\PNServer;
5 5
 
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
         $der  = self::p256PrivateKey($strPrivateKey);
70 70
         $der .= $strPublicKey;
71 71
     
72
-        $pem = '-----BEGIN EC PRIVATE KEY-----'.PHP_EOL;
72
+        $pem = '-----BEGIN EC PRIVATE KEY-----' . PHP_EOL;
73 73
         $pem .= chunk_split(base64_encode($der), 64, PHP_EOL);
74
-        $pem .= '-----END EC PRIVATE KEY-----'.PHP_EOL;
74
+        $pem .= '-----END EC PRIVATE KEY-----' . PHP_EOL;
75 75
     
76 76
         return $pem;
77 77
     }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
         }
127 127
         
128 128
         if ($R !== false && $S !== false) {
129
-            $sig = \pack('H*', $R.$S);
129
+            $sig = \pack('H*', $R . $S);
130 130
         }
131 131
     
132 132
         return $sig;
Please login to merge, or discard this patch.
SKien/PNServer/Utils/Math.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -120,17 +120,17 @@
 block discarded – undo
120 120
     }
121 121
     
122 122
     public static function modSub(\GMP $minuend, \GMP $subtrahend, \GMP $modulus) : \GMP
123
-   	{
124
-   		return self::mod(self::sub($minuend, $subtrahend), $modulus);
125
-   	}
123
+        {
124
+            return self::mod(self::sub($minuend, $subtrahend), $modulus);
125
+        }
126 126
     
127
-   	public static function modMul(\GMP $multiplier, \GMP $muliplicand, \GMP $modulus) : \GMP
128
-   	{
129
-   		return self::mod(self::mul($multiplier, $muliplicand), $modulus);
130
-   	}
127
+        public static function modMul(\GMP $multiplier, \GMP $muliplicand, \GMP $modulus) : \GMP
128
+        {
129
+            return self::mod(self::mul($multiplier, $muliplicand), $modulus);
130
+        }
131 131
     
132
-   	public static function modDiv(\GMP $dividend, \GMP $divisor, \GMP $modulus) : \GMP
133
-   	{
134
-   		return self::mul($dividend, self::inverseMod($divisor, $modulus));
135
-   	}
132
+        public static function modDiv(\GMP $dividend, \GMP $divisor, \GMP $modulus) : \GMP
133
+        {
134
+            return self::mul($dividend, self::inverseMod($divisor, $modulus));
135
+        }
136 136
 }
Please login to merge, or discard this patch.
SKien/PNServer/Utils/Curve.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@
 block discarded – undo
96 96
             if (!$mul->isInfinity()) {
97 97
                 throw new \RuntimeException('SELF * ORDER MUST EQUAL INFINITY. (' . (string) $mul . ' found instead)');
98 98
             }
99
-            */
99
+             */
100 100
         }
101 101
 
102 102
         return $point;
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -198,7 +198,7 @@
 block discarded – undo
198 198
         $n = \str_pad(Math::baseConvert(Math::toString($n), 10, 2), $k, '0', STR_PAD_LEFT);
199 199
 
200 200
         for ($i = 0; $i < $k; ++$i) {
201
-            $j = (int)$n[$i];
201
+            $j = (int) $n[$i];
202 202
             Point::cswap($r[0], $r[1], $j ^ 1);
203 203
             $r[0] = $this->add($r[0], $r[1]);
204 204
             $r[1] = $this->getDouble($r[1]);
Please login to merge, or discard this patch.
SKien/PNServer/PNServer.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types = 1);
2
+declare(strict_types=1);
3 3
 
4 4
 namespace SKien\PNServer;
5 5
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      *    
49 49
      * @param PNDataProvider $oDP
50 50
      */
51
-    public function __construct(?PNDataProvider $oDP=null)
51
+    public function __construct(?PNDataProvider $oDP = null)
52 52
     {
53 53
         $this->oDP = $oDP;
54 54
         $this->reset();
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      * set VAPID subject and keys.
79 79
      * @param PNVapid $oVapid
80 80
      */
81
-    public function setVapid (PNVapid $oVapid) : void 
81
+    public function setVapid(PNVapid $oVapid) : void 
82 82
     {
83 83
         $this->oVapid = $oVapid;
84 84
     }
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
     public function setPayload($payload) : void 
91 91
     {
92 92
         if (is_string($payload) || self::className($payload) == 'PNPayload') {
93
-            $this->strPayload = (string)$payload;
93
+            $this->strPayload = (string) $payload;
94 94
         }
95 95
     }
96 96
     
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
      * has only affect, if data loaded through DataProvider 
159 159
      * @param bool $bAutoRemove
160 160
      */
161
-    public function setAutoRemove(bool $bAutoRemove=true) : void 
161
+    public function setAutoRemove(bool $bAutoRemove = true) : void 
162 162
     {
163 163
         $this->bAutoRemove = $bAutoRemove;
164 164
     }
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
     {
180 180
         if (!$this->oVapid) {
181 181
             $this->strError = 'no VAPID-keys set!';
182
-        } elseif(!$this->oVapid->isValid()) {
182
+        } elseif (!$this->oVapid->isValid()) {
183 183
             $this->strError = 'VAPID error: ' . $this->oVapid->getError();
184
-        } elseif(count($this->aSubscription) == 0) {
184
+        } elseif (count($this->aSubscription) == 0) {
185 185
             $this->strError = 'no valid Subscriptions set!';
186 186
         } else {
187 187
             // create multi requests...
Please login to merge, or discard this patch.