@@ -170,12 +170,12 @@ |
||
170 | 170 | */ |
171 | 171 | private function invoke(string $functionName, array $parameters = [], bool $silence = false) { |
172 | 172 | try { |
173 | - if($silence) { |
|
173 | + if ($silence) { |
|
174 | 174 | return @call_user_func_array($functionName, $parameters); |
175 | 175 | } else { |
176 | 176 | return call_user_func_array($functionName, $parameters); |
177 | 177 | } |
178 | - } catch(\Error $e) { |
|
178 | + } catch (\Error $e) { |
|
179 | 179 | $this->trapError($e->getCode(), $e->getMessage()); |
180 | 180 | } |
181 | 181 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @return bool |
82 | 82 | */ |
83 | 83 | public function verify(array $data): bool { |
84 | - if(isset($data['message']) |
|
84 | + if (isset($data['message']) |
|
85 | 85 | && isset($data['signature']) |
86 | 86 | && isset($data['message']['signer']) |
87 | 87 | ) { |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | $userId = substr($data['message']['signer'], 0, $location); |
90 | 90 | |
91 | 91 | $user = $this->userManager->get($userId); |
92 | - if($user !== null) { |
|
92 | + if ($user !== null) { |
|
93 | 93 | $key = $this->keyManager->getKey($user); |
94 | - return (bool)openssl_verify( |
|
94 | + return (bool) openssl_verify( |
|
95 | 95 | json_encode($data['message']), |
96 | 96 | base64_decode($data['signature']), |
97 | 97 | $key->getPublic(), |
@@ -76,7 +76,7 @@ |
||
76 | 76 | $maxCharIndex = \strlen($characters) - 1; |
77 | 77 | $randomString = ''; |
78 | 78 | |
79 | - while($length > 0) { |
|
79 | + while ($length > 0) { |
|
80 | 80 | $randomNumber = \random_int(0, $maxCharIndex); |
81 | 81 | $randomString .= $characters[$randomNumber]; |
82 | 82 | $length--; |
@@ -57,7 +57,7 @@ |
||
57 | 57 | */ |
58 | 58 | public function getToken(): string { |
59 | 59 | $token = $this->session->get('requesttoken'); |
60 | - if(empty($token)) { |
|
60 | + if (empty($token)) { |
|
61 | 61 | throw new \Exception('Session does not contain a requesttoken'); |
62 | 62 | } |
63 | 63 |
@@ -52,9 +52,9 @@ |
||
52 | 52 | * @return string |
53 | 53 | */ |
54 | 54 | public function getEncryptedValue(): string { |
55 | - if($this->encryptedValue === '') { |
|
55 | + if ($this->encryptedValue === '') { |
|
56 | 56 | $sharedSecret = random_bytes(\strlen($this->value)); |
57 | - $this->encryptedValue = base64_encode($this->value ^ $sharedSecret) . ':' . base64_encode($sharedSecret); |
|
57 | + $this->encryptedValue = base64_encode($this->value ^ $sharedSecret).':'.base64_encode($sharedSecret); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | return $this->encryptedValue; |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | * @return CsrfToken |
55 | 55 | */ |
56 | 56 | public function getToken(): CsrfToken { |
57 | - if(!\is_null($this->csrfToken)) { |
|
57 | + if (!\is_null($this->csrfToken)) { |
|
58 | 58 | return $this->csrfToken; |
59 | 59 | } |
60 | 60 | |
61 | - if($this->sessionStorage->hasToken()) { |
|
61 | + if ($this->sessionStorage->hasToken()) { |
|
62 | 62 | $value = $this->sessionStorage->getToken(); |
63 | 63 | } else { |
64 | 64 | $value = $this->tokenGenerator->generateToken(); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @return bool |
97 | 97 | */ |
98 | 98 | public function isTokenValid(CsrfToken $token): bool { |
99 | - if(!$this->sessionStorage->hasToken()) { |
|
99 | + if (!$this->sessionStorage->hasToken()) { |
|
100 | 100 | return false; |
101 | 101 | } |
102 | 102 |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | private function hash(string $methodIdentifier, |
59 | 59 | string $userIdentifier): string { |
60 | - return hash('sha512', $methodIdentifier . $userIdentifier); |
|
60 | + return hash('sha512', $methodIdentifier.$userIdentifier); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | } |
72 | 72 | |
73 | 73 | $cachedAttempts = json_decode($cachedAttempts, true); |
74 | - if(\is_array($cachedAttempts)) { |
|
74 | + if (\is_array($cachedAttempts)) { |
|
75 | 75 | return $cachedAttempts; |
76 | 76 | } |
77 | 77 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $currentTime = $this->timeFactory->getTime(); |
92 | 92 | /** @var array $existingAttempts */ |
93 | 93 | foreach ($existingAttempts as $attempt) { |
94 | - if(($attempt + $seconds) > $currentTime) { |
|
94 | + if (($attempt + $seconds) > $currentTime) { |
|
95 | 95 | $count++; |
96 | 96 | } |
97 | 97 | } |
@@ -111,14 +111,14 @@ discard block |
||
111 | 111 | |
112 | 112 | // Unset all attempts older than $period |
113 | 113 | foreach ($existingAttempts as $key => $attempt) { |
114 | - if(($attempt + $period) < $currentTime) { |
|
114 | + if (($attempt + $period) < $currentTime) { |
|
115 | 115 | unset($existingAttempts[$key]); |
116 | 116 | } |
117 | 117 | } |
118 | 118 | $existingAttempts = array_values($existingAttempts); |
119 | 119 | |
120 | 120 | // Store the new attempt |
121 | - $existingAttempts[] = (string)$currentTime; |
|
121 | + $existingAttempts[] = (string) $currentTime; |
|
122 | 122 | $this->cache->set($identifier, json_encode($existingAttempts)); |
123 | 123 | } |
124 | 124 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function getCapabilities(bool $public = false) : array { |
53 | 53 | $capabilities = []; |
54 | - foreach($this->capabilities as $capability) { |
|
54 | + foreach ($this->capabilities as $capability) { |
|
55 | 55 | try { |
56 | 56 | $c = $capability(); |
57 | 57 | } catch (QueryException $e) { |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | if ($c instanceof ICapability) { |
67 | - if(!$public || $c instanceof IPublicCapability) { |
|
67 | + if (!$public || $c instanceof IPublicCapability) { |
|
68 | 68 | $capabilities = array_replace_recursive($capabilities, $c->getCapabilities()); |
69 | 69 | } |
70 | 70 | } else { |
71 | - throw new \InvalidArgumentException('The given Capability (' . get_class($c) . ') does not implement the ICapability interface'); |
|
71 | + throw new \InvalidArgumentException('The given Capability ('.get_class($c).') does not implement the ICapability interface'); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 |
@@ -62,7 +62,7 @@ |
||
62 | 62 | */ |
63 | 63 | public function addEntityCollection(string $name, \Closure $entityExistsFunction) { |
64 | 64 | if (isset($this->collections[$name])) { |
65 | - throw new \OutOfBoundsException('Duplicate entity name "' . $name . '"'); |
|
65 | + throw new \OutOfBoundsException('Duplicate entity name "'.$name.'"'); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | $this->collections[$name] = $entityExistsFunction; |