Skip to content

Commit 0b906dd

Browse files
committed
fix PSR-1 camelCase method name
1 parent 8fa54ba commit 0b906dd

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/Encryption.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ final class Encryption
2626
*/
2727
public static function padPayload($payload, $automatic)
2828
{
29-
$payloadLen = Utils::safe_strlen($payload);
29+
$payloadLen = Utils::safeStrlen($payload);
3030
$padLen = $automatic ? self::MAX_PAYLOAD_LENGTH - $payloadLen : 0;
3131
return pack('n*', $padLen).str_pad($payload, $padLen + $payloadLen, chr(0), STR_PAD_LEFT);
3232
}
@@ -138,12 +138,12 @@ private static function hkdf($salt, $ikm, $info, $length)
138138
*/
139139
private static function createContext($clientPublicKey, $serverPublicKey)
140140
{
141-
if (Utils::safe_strlen($clientPublicKey) !== 65) {
141+
if (Utils::safeStrlen($clientPublicKey) !== 65) {
142142
throw new \ErrorException('Invalid client public key length');
143143
}
144144

145145
// This one should never happen, because it's our code that generates the key
146-
if (Utils::safe_strlen($serverPublicKey) !== 65) {
146+
if (Utils::safeStrlen($serverPublicKey) !== 65) {
147147
throw new \ErrorException('Invalid server public key length');
148148
}
149149

@@ -163,7 +163,7 @@ private static function createContext($clientPublicKey, $serverPublicKey)
163163
* @throws \ErrorException
164164
*/
165165
private static function createInfo($type, $context) {
166-
if (Utils::safe_strlen($context) !== 135) {
166+
if (Utils::safeStrlen($context) !== 135) {
167167
throw new \ErrorException('Context argument has invalid size');
168168
}
169169

src/Utils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
class Utils
1515
{
16-
public static function safe_strlen($string) {
16+
public static function safeStrlen($string) {
1717
return mb_strlen($string, "8bit");
1818
}
1919
}

src/WebPush.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function __construct(array $apiKeys = array(), $defaultOptions = array(),
7575
public function sendNotification($endpoint, $payload = null, $userPublicKey = null, $userAuthToken = null, $flush = false, $options = array())
7676
{
7777
if(isset($payload)) {
78-
if (Utils::safe_strlen($payload) > Encryption::MAX_PAYLOAD_LENGTH) {
78+
if (Utils::safeStrlen($payload) > Encryption::MAX_PAYLOAD_LENGTH) {
7979
throw new \ErrorException('Size of payload must not be greater than '.Encryption::MAX_PAYLOAD_LENGTH.' octets.');
8080
}
8181

@@ -178,7 +178,7 @@ private function prepareAndSend(array $notifications)
178178
$encrypted = Encryption::encrypt($payload, $userPublicKey, $userAuthToken, $this->nativePayloadEncryptionSupport);
179179

180180
$headers = array(
181-
'Content-Length' => Utils::safe_strlen($encrypted['cipherText']),
181+
'Content-Length' => Utils::safeStrlen($encrypted['cipherText']),
182182
'Content-Type' => 'application/octet-stream',
183183
'Content-Encoding' => 'aesgcm',
184184
'Encryption' => 'keyid="p256dh";salt="'.$encrypted['salt'].'"',
@@ -204,7 +204,7 @@ private function prepareAndSend(array $notifications)
204204
$headers['Topic'] = $options['topic'];
205205
}
206206

207-
if (substr($endpoint, 0, Utils::safe_strlen(self::GCM_URL)) === self::GCM_URL) {
207+
if (substr($endpoint, 0, strlen(self::GCM_URL)) === self::GCM_URL) {
208208
if (array_key_exists('GCM', $this->apiKeys)) {
209209
$headers['Authorization'] = 'key='.$this->apiKeys['GCM'];
210210
} else {

tests/EncryptionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function testPadPayload($payload)
2424
$res = Encryption::padPayload($payload, true);
2525

2626
$this->assertContains('test', $res);
27-
$this->assertEquals(4080, Utils::safe_strlen($res));
27+
$this->assertEquals(4080, Utils::safeStrlen($res));
2828
}
2929

3030
public function payloadProvider()

0 commit comments

Comments
 (0)