Skip to content

Commit ab524f9

Browse files
committed
whitespace fixes
1 parent aee5981 commit ab524f9

File tree

6 files changed

+143
-143
lines changed

6 files changed

+143
-143
lines changed

lib/Mailer.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ public static function getMailer() {
1414
// Settings
1515
$mailer->IsSMTP();
1616
$mailer->CharSet = 'UTF-8';
17-
$mailer->Host = MAILER['host'];
18-
$mailer->SMTPDebug = 0;
19-
$mailer->Port = MAILER['port'];
17+
$mailer->Host = MAILER['host'];
18+
$mailer->SMTPDebug = 0;
19+
$mailer->Port = MAILER['port'];
2020
if (isset(MAILER['user'])) {
21-
$mailer->SMTPAuth = true;
22-
$mailer->Username = MAILER['user'];
23-
$mailer->Password = MAILER['password'];
21+
$mailer->SMTPAuth = true;
22+
$mailer->Username = MAILER['user'];
23+
$mailer->Password = MAILER['password'];
2424
}
2525
$mailer->isHTML(true);
2626
$mailer->setFrom(MAILER['from']);
@@ -50,7 +50,7 @@ public static function sendAccountCreated($data) {
5050
$mailer->addAddress($mailTo);
5151

5252
$mailer->Subject = $mailSubject;
53-
$mailer->Body = $mailHtmlBody;
53+
$mailer->Body = $mailHtmlBody;
5454
$mailer->AltBody = $mailPlainBody;
5555

5656
$mailer->send();
@@ -79,7 +79,7 @@ public static function sendVerify($data) {
7979
$mailer->addAddress($mailTo);
8080

8181
$mailer->Subject = $mailSubject;
82-
$mailer->Body = $mailHtmlBody;
82+
$mailer->Body = $mailHtmlBody;
8383
$mailer->AltBody = $mailPlainBody;
8484

8585
$mailer->send();
@@ -107,7 +107,7 @@ public static function sendResetPassword($data) {
107107
$mailer->addAddress($mailTo);
108108

109109
$mailer->Subject = $mailSubject;
110-
$mailer->Body = $mailHtmlBody;
110+
$mailer->Body = $mailHtmlBody;
111111
$mailer->AltBody = $mailPlainBody;
112112

113113
$mailer->send();
@@ -135,7 +135,7 @@ public static function sendDeleteAccount($data) {
135135
$mailer->addAddress($mailTo);
136136

137137
$mailer->Subject = $mailSubject;
138-
$mailer->Body = $mailHtmlBody;
138+
$mailer->Body = $mailHtmlBody;
139139
$mailer->AltBody = $mailPlainBody;
140140

141141
$mailer->send();

lib/PasswordValidator.php

Lines changed: 96 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,114 @@
11
<?php
22
/*
3-
Code modified from https://gitlab.com/garybell/password-validation/ (MIT licensed)
3+
Code modified from https://gitlab.com/garybell/password-validation/ (MIT licensed)
44
*/
55
namespace Pdsinterop\PhpSolid;
66

77
class PasswordValidator
88
{
9-
private static string $specialCharacters = ' !"#$%&\'()*+,-./:;<=>?@[\]^_{|}~';
10-
private static string $lowercaseCharacters = 'abcdefghijklmnopqrstuvwxyz';
11-
private static string $uppercaseCharacters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
12-
private static string $numbers = '0123456789';
9+
private static string $specialCharacters = ' !"#$%&\'()*+,-./:;<=>?@[\]^_{|}~';
10+
private static string $lowercaseCharacters = 'abcdefghijklmnopqrstuvwxyz';
11+
private static string $uppercaseCharacters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
12+
private static string $numbers = '0123456789';
1313

14-
/**
15-
* The maximum number of times the same character can appear in the password
16-
* @var int
17-
*/
18-
private static int $maxOccurrences = 2;
14+
/**
15+
* The maximum number of times the same character can appear in the password
16+
* @var int
17+
*/
18+
private static int $maxOccurrences = 2;
1919

20-
/**
21-
* Get the base amount of characters from the characters used in the password.
22-
* This is the number of possible characters to pick from in the used character sets
23-
* i.e. 26 for only lower case passwords
24-
* @param $password
25-
* @return int
26-
*/
27-
public static function getBase(string $password): int
28-
{
29-
$characters = str_split($password);
30-
$base = 0;
31-
$hasSpecial = false;
32-
$hasLower = false;
33-
$hasUpper = false;
34-
$hasDigits = false;
20+
/**
21+
* Get the base amount of characters from the characters used in the password.
22+
* This is the number of possible characters to pick from in the used character sets
23+
* i.e. 26 for only lower case passwords
24+
* @param $password
25+
* @return int
26+
*/
27+
public static function getBase(string $password): int
28+
{
29+
$characters = str_split($password);
30+
$base = 0;
31+
$hasSpecial = false;
32+
$hasLower = false;
33+
$hasUpper = false;
34+
$hasDigits = false;
3535

36-
foreach ($characters as $character) {
37-
if (!$hasLower && strpos(self::$lowercaseCharacters, $character) !== false) {
38-
$hasLower = true;
39-
$base += strlen(self::$lowercaseCharacters);
40-
}
41-
if (!$hasUpper && strpos(self::$uppercaseCharacters, $character) !== false) {
42-
$hasUpper = true;
43-
$base += strlen(self::$uppercaseCharacters);
44-
}
45-
if (!$hasSpecial && strpos(self::$specialCharacters, $character) !== false) {
46-
$hasSpecial = true;
47-
$base += strlen(self::$specialCharacters);
48-
}
49-
if (!$hasDigits && strpos(self::$numbers, $character) !== false) {
50-
$hasDigits = true;
51-
$base += strlen(self::$numbers);
52-
}
36+
foreach ($characters as $character) {
37+
if (!$hasLower && strpos(self::$lowercaseCharacters, $character) !== false) {
38+
$hasLower = true;
39+
$base += strlen(self::$lowercaseCharacters);
40+
}
41+
if (!$hasUpper && strpos(self::$uppercaseCharacters, $character) !== false) {
42+
$hasUpper = true;
43+
$base += strlen(self::$uppercaseCharacters);
44+
}
45+
if (!$hasSpecial && strpos(self::$specialCharacters, $character) !== false) {
46+
$hasSpecial = true;
47+
$base += strlen(self::$specialCharacters);
48+
}
49+
if (!$hasDigits && strpos(self::$numbers, $character) !== false) {
50+
$hasDigits = true;
51+
$base += strlen(self::$numbers);
52+
}
5353

54-
if (
55-
strpos(self::$lowercaseCharacters, $character) === false
56-
&& strpos(self::$uppercaseCharacters, $character) === false
57-
&& strpos(self::$specialCharacters, $character) === false
58-
&& strpos(self::$numbers, $character) === false
59-
) {
60-
$base++;
61-
}
62-
}
54+
if (
55+
strpos(self::$lowercaseCharacters, $character) === false
56+
&& strpos(self::$uppercaseCharacters, $character) === false
57+
&& strpos(self::$specialCharacters, $character) === false
58+
&& strpos(self::$numbers, $character) === false
59+
) {
60+
$base++;
61+
}
62+
}
6363

64-
return $base;
65-
}
64+
return $base;
65+
}
6666

67-
/**
68-
* get the calculated entropy of the password based on the rules for excluding duplicate characters
69-
* If a password is in the banned list, entropy will be 0.
70-
* @see bannedPassords()
71-
* @param string $password
72-
* @param array $bannedPasswords a custom list of passwords to disallow
73-
* @return float
74-
*/
75-
public static function getEntropy(string $password, array $bannedPasswords = []): float
76-
{
77-
if (in_array(strtolower($password), $bannedPasswords)) {
78-
// these are so weak, we just want to outright ban them. Entropy will be 0 for anything in this list.
79-
return 0;
80-
}
81-
$base = self::getBase($password);
82-
$length = self::getLength($password);
67+
/**
68+
* get the calculated entropy of the password based on the rules for excluding duplicate characters
69+
* If a password is in the banned list, entropy will be 0.
70+
* @see bannedPassords()
71+
* @param string $password
72+
* @param array $bannedPasswords a custom list of passwords to disallow
73+
* @return float
74+
*/
75+
public static function getEntropy(string $password, array $bannedPasswords = []): float
76+
{
77+
if (in_array(strtolower($password), $bannedPasswords)) {
78+
// these are so weak, we just want to outright ban them. Entropy will be 0 for anything in this list.
79+
return 0;
80+
}
81+
$base = self::getBase($password);
82+
$length = self::getLength($password);
8383

84-
$decimalPlaces = 2;
85-
return number_format(log($base ** $length), $decimalPlaces);
86-
}
84+
$decimalPlaces = 2;
85+
return number_format(log($base ** $length), $decimalPlaces);
86+
}
8787

88-
/**
89-
* Check the length of the password based on known rules
90-
* Characters will only be counted a maximum of 2 times e.g. aaa has length 2
91-
* @param $password
92-
* @return int
93-
*/
94-
public static function getLength(string $password): int
95-
{
96-
$usedCharacters = [];
97-
$characters = str_split($password);
98-
$length = 0;
88+
/**
89+
* Check the length of the password based on known rules
90+
* Characters will only be counted a maximum of 2 times e.g. aaa has length 2
91+
* @param $password
92+
* @return int
93+
*/
94+
public static function getLength(string $password): int
95+
{
96+
$usedCharacters = [];
97+
$characters = str_split($password);
98+
$length = 0;
9999

100-
foreach ($characters as $character)
101-
{
102-
if (array_key_exists($character, $usedCharacters) && $usedCharacters[$character] < self::$maxOccurrences) {
103-
$length++;
104-
$usedCharacters[$character]++;
105-
}
106-
if (!array_key_exists($character, $usedCharacters)) {
107-
$usedCharacters[$character] = 1;
108-
$length++;
109-
}
110-
}
100+
foreach ($characters as $character)
101+
{
102+
if (array_key_exists($character, $usedCharacters) && $usedCharacters[$character] < self::$maxOccurrences) {
103+
$length++;
104+
$usedCharacters[$character]++;
105+
}
106+
if (!array_key_exists($character, $usedCharacters)) {
107+
$usedCharacters[$character] = 1;
108+
$length++;
109+
}
110+
}
111111

112-
return $length;
113-
}
112+
return $length;
113+
}
114114
}

lib/Routes/Account.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22
namespace Pdsinterop\PhpSolid\Routes;
33

4-
use Pdsinterop\PhpSolid\Server;
5-
use Pdsinterop\PhpSolid\ClientRegistration;
6-
use Pdsinterop\PhpSolid\User;
7-
use Pdsinterop\PhpSolid\Session;
8-
use Pdsinterop\PhpSolid\Mailer;
9-
use Pdsinterop\PhpSolid\IpAttempts;
4+
use Pdsinterop\PhpSolid\Server;
5+
use Pdsinterop\PhpSolid\ClientRegistration;
6+
use Pdsinterop\PhpSolid\User;
7+
use Pdsinterop\PhpSolid\Session;
8+
use Pdsinterop\PhpSolid\Mailer;
9+
use Pdsinterop\PhpSolid\IpAttempts;
1010

1111
class Account {
1212
public static function requireLoggedInUser() {

lib/Routes/SolidIdp.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
22
namespace Pdsinterop\PhpSolid\Routes;
33

4-
use Pdsinterop\PhpSolid\Server;
5-
use Pdsinterop\PhpSolid\ClientRegistration;
6-
use Pdsinterop\PhpSolid\User;
7-
use Pdsinterop\PhpSolid\Session;
4+
use Pdsinterop\PhpSolid\Server;
5+
use Pdsinterop\PhpSolid\ClientRegistration;
6+
use Pdsinterop\PhpSolid\User;
7+
use Pdsinterop\PhpSolid\Session;
88

99
class SolidIdp {
1010
public static function respondToJwks() {

lib/SolidPubSub.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
<?php
2-
namespace Pdsinterop\PhpSolid;
2+
namespace Pdsinterop\PhpSolid;
33

4-
use WebSocket\Client;
5-
use Pdsinterop\Solid\SolidNotifications\SolidNotificationsInterface;
4+
use WebSocket\Client;
5+
use Pdsinterop\Solid\SolidNotifications\SolidNotificationsInterface;
66

7-
class SolidPubSub implements SolidNotificationsInterface
8-
{
9-
private $pubsub;
10-
public function __construct($pubsubUrl) {
11-
$this->pubsub = $pubsubUrl;
12-
}
7+
class SolidPubSub implements SolidNotificationsInterface
8+
{
9+
private $pubsub;
10+
public function __construct($pubsubUrl) {
11+
$this->pubsub = $pubsubUrl;
12+
}
1313

14-
public function send($path, $type) {
15-
$pubsub = str_replace(["https://", "http://"], "wss://", $this->pubsub);
14+
public function send($path, $type) {
15+
$pubsub = str_replace(["https://", "http://"], "wss://", $this->pubsub);
1616

17-
$client = new Client($pubsub);
18-
$client->setContext(['ssl' => [
19-
'verify_peer' => false, // if false, accept SSL handshake without client certificate
20-
'verify_peer_name' => false,
21-
'allow_self_signed' => true,
22-
]]);
23-
$client->addHeader("Sec-WebSocket-Protocol", "solid-0.1");
24-
try {
25-
$client->text("pub $path\n");
26-
} catch (\Throwable $exception) {
27-
throw new \Exception('Could not write to pubsub server', 502, $exception);
28-
}
29-
}
30-
}
17+
$client = new Client($pubsub);
18+
$client->setContext(['ssl' => [
19+
'verify_peer' => false, // if false, accept SSL handshake without client certificate
20+
'verify_peer_name' => false,
21+
'allow_self_signed' => true,
22+
]]);
23+
$client->addHeader("Sec-WebSocket-Protocol", "solid-0.1");
24+
try {
25+
$client->text("pub $path\n");
26+
} catch (\Throwable $exception) {
27+
throw new \Exception('Could not write to pubsub server', 502, $exception);
28+
}
29+
}
30+
}

lib/StorageServer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ public static function getFileSystem() {
1010

1111
// The internal adapter
1212
$adapter = new \League\Flysystem\Adapter\Local(
13-
// Determine root directory
14-
STORAGEBASE . "$storageId/"
13+
// Determine root directory
14+
STORAGEBASE . "$storageId/"
1515
);
1616

1717
$graph = new \EasyRdf\Graph();

0 commit comments

Comments
 (0)