Skip to content

Commit 7f83254

Browse files
committed
Fix PHP Codesniffer whitespace violations.
1 parent c2c7557 commit 7f83254

28 files changed

Lines changed: 599 additions & 388 deletions

init.php

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,90 @@
11
<?php
22

3+
// phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact
34
// phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols
45

56
require_once(__DIR__ . "/config.php");
67
require_once(__DIR__ . "/vendor/autoload.php");
7-
8+
89
use Pdsinterop\PhpSolid\Server;
9-
10-
function initKeys() {
10+
11+
function initKeys()
12+
{
1113
$keys = Server::generateKeySet();
1214
file_put_contents(KEYDIR . "public.key", $keys['publicKey']);
1315
file_put_contents(KEYDIR . "private.key", $keys['privateKey']);
1416
file_put_contents(KEYDIR . "encryption.key", $keys['encryptionKey']);
1517
}
1618

17-
function initDatabase() {
19+
function initDatabase()
20+
{
1821
$statements = [
19-
'CREATE TABLE IF NOT EXISTS clients (
22+
'CREATE TABLE IF NOT EXISTS clients (
2023
clientId VARCHAR(255) NOT NULL PRIMARY KEY,
2124
origin TEXT NOT NULL,
2225
clientData TEXT NOT NULL
23-
)',
24-
'CREATE TABLE IF NOT EXISTS allowedClients (
26+
)',
27+
'CREATE TABLE IF NOT EXISTS allowedClients (
2528
userId VARCHAR(255) NOT NULL PRIMARY KEY,
2629
clientId VARCHAR(255) NOT NULL
27-
)',
28-
'CREATE TABLE IF NOT EXISTS userStorage (
30+
)',
31+
'CREATE TABLE IF NOT EXISTS userStorage (
2932
userId VARCHAR(255) NOT NULL PRIMARY KEY,
3033
storageUrl VARCHAR(255) NOT NULL
31-
)',
32-
'CREATE TABLE IF NOT EXISTS verify (
34+
)',
35+
'CREATE TABLE IF NOT EXISTS verify (
3336
code VARCHAR(255) NOT NULL PRIMARY KEY,
3437
data TEXT NOT NULL
35-
)',
36-
'CREATE TABLE IF NOT EXISTS jti (
38+
)',
39+
'CREATE TABLE IF NOT EXISTS jti (
3740
jti VARCHAR(255) NOT NULL PRIMARY KEY,
3841
expires TEXT NOT NULL
39-
)',
40-
'CREATE TABLE IF NOT EXISTS users (
42+
)',
43+
'CREATE TABLE IF NOT EXISTS users (
4144
user_id VARCHAR(255) NOT NULL PRIMARY KEY,
4245
email TEXT NOT NULL,
4346
password TEXT NOT NULL,
4447
data TEXT
45-
)',
46-
'CREATE TABLE IF NOT EXISTS ipAttempts (
48+
)',
49+
'CREATE TABLE IF NOT EXISTS ipAttempts (
4750
ip VARCHAR(255) NOT NULL,
4851
type VARCHAR(255) NOT NULL,
4952
expires TEXT NOT NULL
50-
)',
53+
)',
5154
];
52-
55+
5356
try {
54-
$pdo = new \PDO("sqlite:" . DBPATH);
57+
$pdo = new \PDO("sqlite:" . DBPATH);
5558

56-
// create tables
57-
foreach($statements as $statement){
59+
// create tables
60+
foreach ($statements as $statement) {
5861
$pdo->exec($statement);
59-
}
60-
} catch(\PDOException $e) {
61-
echo $e->getMessage();
62+
}
63+
} catch (\PDOException $e) {
64+
echo $e->getMessage();
6265
}
6366
}
6467

65-
function initStorageDatabase() {
68+
function initStorageDatabase()
69+
{
6670
$statements = [
67-
'CREATE TABLE IF NOT EXISTS storage (
71+
'CREATE TABLE IF NOT EXISTS storage (
6872
storage_id VARCHAR(255) NOT NULL PRIMARY KEY,
6973
owner VARCHAR(255) NOT NULL
70-
)'
74+
)'
7175
];
7276

7377
try {
74-
$pdo = new \PDO("sqlite:" . DBPATH);
78+
$pdo = new \PDO("sqlite:" . DBPATH);
7579

76-
// create tables
77-
foreach($statements as $statement){
78-
$pdo->exec($statement);
79-
}
80-
} catch(\PDOException $e) {
81-
echo $e->getMessage();
80+
// create tables
81+
foreach ($statements as $statement) {
82+
$pdo->exec($statement);
83+
}
84+
} catch (\PDOException $e) {
85+
echo $e->getMessage();
8286
}
8387
}
8488
initKeys();
8589
initDatabase();
86-
initStorageDatabase();
90+
initStorageDatabase();

lib/ClientRegistration.php

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
<?php
2+
3+
// phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact
4+
25
namespace Pdsinterop\PhpSolid;
36

47
use Pdsinterop\PhpSolid\Db;
58

6-
class ClientRegistration {
7-
public static function getRegistration($clientId) {
9+
class ClientRegistration
10+
{
11+
public static function getRegistration($clientId)
12+
{
813
Db::connect();
914
$query = Db::$pdo->prepare(
1015
'SELECT clientData FROM clients WHERE clientId=:clientId'
@@ -27,7 +32,8 @@ public static function getRegistration($clientId) {
2732
return false;
2833
}
2934

30-
public static function getRemoteRegistration($url) {
35+
public static function getRemoteRegistration($url)
36+
{
3137
$clientDocument = file_get_contents($url);
3238
$clientRegistration = json_decode($clientDocument, true);
3339
if (!isset($clientRegistration['client_id'])) {
@@ -39,7 +45,8 @@ public static function getRemoteRegistration($url) {
3945
return $clientRegistration;
4046
}
4147

42-
public static function saveClientRegistration($clientData) {
48+
public static function saveClientRegistration($clientData)
49+
{
4350
Db::connect();
4451
if (!isset($clientData['client_name'])) {
4552
$clientData['client_name'] = $clientData['origin'];
@@ -53,8 +60,9 @@ public static function saveClientRegistration($clientData) {
5360
':clientData' => json_encode($clientData)
5461
]);
5562
}
56-
57-
public static function getClientByOrigin($origin) {
63+
64+
public static function getClientByOrigin($origin)
65+
{
5866
Db::connect();
5967
$query = Db::$pdo->prepare(
6068
'SELECT clientData FROM clients WHERE origin=:origin'
@@ -63,10 +71,10 @@ public static function getClientByOrigin($origin) {
6371
':origin' => $origin
6472
]);
6573
$result = $query->fetchAll();
66-
67-
if (sizeof($result)=== 1) {
74+
75+
if (sizeof($result) === 1) {
6876
return json_decode($result[0]['clientData'], true);
6977
}
7078
return false;
7179
}
72-
}
80+
}

lib/Db.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
<?php
2+
3+
// phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact
4+
25
namespace Pdsinterop\PhpSolid;
3-
4-
class Db {
6+
7+
class Db
8+
{
59
public static $pdo;
6-
public static function connect() {
10+
public static function connect()
11+
{
712
if (!isset(self::$pdo)) {
813
self::$pdo = new \PDO("sqlite:" . DBPATH);
914
}

lib/IpAttempts.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
<?php
2+
3+
// phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact
4+
25
namespace Pdsinterop\PhpSolid;
36

47
use Pdsinterop\PhpSolid\Db;
58

6-
class IpAttempts {
7-
public static function logFailedAttempt($ip, $type, $expires) {
9+
class IpAttempts
10+
{
11+
public static function logFailedAttempt($ip, $type, $expires)
12+
{
813
if (in_array($ip, TRUSTED_IPS)) {
914
return;
1015
}
1116

1217
Db::connect();
13-
18+
1419
$query = Db::$pdo->prepare(
1520
'INSERT INTO ipAttempts VALUES(:ip, :type, :expires)'
1621
);
@@ -21,7 +26,8 @@ public static function logFailedAttempt($ip, $type, $expires) {
2126
]);
2227
}
2328

24-
public static function getAttemptsCount($ip, $type) {
29+
public static function getAttemptsCount($ip, $type)
30+
{
2531
if (in_array($ip, TRUSTED_IPS)) {
2632
return 0;
2733
}
@@ -43,9 +49,10 @@ public static function getAttemptsCount($ip, $type) {
4349
}
4450
return 0;
4551
}
46-
public static function cleanupAttempts() {
52+
public static function cleanupAttempts()
53+
{
4754
Db::connect();
48-
55+
4956
$now = new \DateTime();
5057
$query = Db::$pdo->prepare(
5158
'DELETE FROM ipAttempts WHERE expires < :now'

lib/JtiStore.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
<?php
2+
3+
// phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact
4+
25
namespace Pdsinterop\PhpSolid;
36

47
use Pdsinterop\PhpSolid\Db;
5-
class JtiStore {
6-
public static function hasJti($jti) {
8+
9+
class JtiStore
10+
{
11+
public static function hasJti($jti)
12+
{
713
Db::connect();
814
$now = new \DateTime();
915
$query = Db::$pdo->prepare(
@@ -19,8 +25,9 @@ public static function hasJti($jti) {
1925
}
2026
return false;
2127
}
22-
23-
public static function saveJti($jti) {
28+
29+
public static function saveJti($jti)
30+
{
2431
Db::connect();
2532
$query = Db::$pdo->prepare(
2633
'INSERT INTO jti VALUES(:jti, :expires)'
@@ -33,7 +40,8 @@ public static function saveJti($jti) {
3340
]);
3441
}
3542

36-
public static function cleanupJti() {
43+
public static function cleanupJti()
44+
{
3745
Db::connect();
3846
$now = new \DateTime();
3947
$query = Db::$pdo->prepare(
@@ -43,4 +51,4 @@ public static function cleanupJti() {
4351
':now' => $now->getTimestamp()
4452
]);
4553
}
46-
}
54+
}

0 commit comments

Comments
 (0)