mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Code cleanup
This commit is contained in:
@@ -44,8 +44,6 @@ class Alias extends BunqObject
|
||||
$this->type = $data['type'];
|
||||
$this->name = $data['name'];
|
||||
$this->value = $data['value'];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,7 +42,6 @@ class Amount extends BunqObject
|
||||
$this->currency = $data['currency'];
|
||||
$this->value = $data['value'];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -81,6 +81,7 @@ class DeviceServer extends BunqObject
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
|
||||
@@ -73,6 +73,7 @@ class LabelMonetaryAccount extends BunqObject
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
|
||||
@@ -80,6 +80,7 @@ class LabelUser extends BunqObject
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
|
||||
@@ -52,7 +52,6 @@ class MonetaryAccountProfile extends BunqObject
|
||||
$this->profileActionRequired = $data['profile_action_required'];
|
||||
$this->profileAmountRequired = new Amount($data['profile_amount_required']);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,7 +45,6 @@ class MonetaryAccountSetting extends BunqObject
|
||||
$this->defaultAvatarStatus = $data['default_avatar_status'];
|
||||
$this->restrictionChat = $data['restriction_chat'];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -135,6 +135,7 @@ class Payment extends BunqObject
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
|
||||
@@ -60,7 +60,7 @@ class UserLight extends BunqObject
|
||||
*/
|
||||
public function __construct(array $data)
|
||||
{
|
||||
if (0 === count($data)) {
|
||||
if (0 === \count($data)) {
|
||||
return;
|
||||
}
|
||||
$this->id = (int)$data['id'];
|
||||
@@ -78,6 +78,7 @@ class UserLight extends BunqObject
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
|
||||
@@ -120,7 +120,7 @@ class UserPerson extends BunqObject
|
||||
*/
|
||||
public function __construct(array $data)
|
||||
{
|
||||
if (0 === count($data)) {
|
||||
if (0 === \count($data)) {
|
||||
$this->created = new Carbon;
|
||||
$this->updated = new Carbon;
|
||||
$this->dateOfBirth = new Carbon;
|
||||
|
||||
@@ -119,7 +119,7 @@ abstract class BunqRequest
|
||||
*/
|
||||
protected function generateSignature(string $method, string $uri, array $headers, string $data): string
|
||||
{
|
||||
if (0 === strlen($this->privateKey)) {
|
||||
if (0 === \strlen($this->privateKey)) {
|
||||
throw new FireflyException('No private key present.');
|
||||
}
|
||||
if ('get' === strtolower($method) || 'delete' === strtolower($method)) {
|
||||
@@ -133,7 +133,7 @@ abstract class BunqRequest
|
||||
$headersToSign = ['Cache-Control', 'User-Agent'];
|
||||
ksort($headers);
|
||||
foreach ($headers as $name => $value) {
|
||||
if (in_array($name, $headersToSign) || 'X-Bunq-' === substr($name, 0, 7)) {
|
||||
if (\in_array($name, $headersToSign) || 'X-Bunq-' === substr($name, 0, 7)) {
|
||||
$toSign .= sprintf("%s: %s\n", $name, $value);
|
||||
}
|
||||
}
|
||||
@@ -217,7 +217,7 @@ abstract class BunqRequest
|
||||
*/
|
||||
protected function sendSignedBunqDelete(string $uri, array $headers): array
|
||||
{
|
||||
if (0 === strlen($this->server)) {
|
||||
if (0 === \strlen($this->server)) {
|
||||
throw new FireflyException('No bunq server defined');
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ abstract class BunqRequest
|
||||
*/
|
||||
protected function sendSignedBunqGet(string $uri, array $data, array $headers): array
|
||||
{
|
||||
if (0 === strlen($this->server)) {
|
||||
if (0 === \strlen($this->server)) {
|
||||
throw new FireflyException('No bunq server defined');
|
||||
}
|
||||
|
||||
@@ -508,12 +508,12 @@ abstract class BunqRequest
|
||||
$dataToVerify .= "\n" . $body;
|
||||
$result = openssl_verify($dataToVerify, base64_decode($signature), $this->serverPublicKey->getPublicKey(), OPENSSL_ALGO_SHA256);
|
||||
|
||||
if (is_int($result) && $result < 1) {
|
||||
if (\is_int($result) && $result < 1) {
|
||||
Log::error(sprintf('Result of verification is %d, return false.', $result));
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!is_int($result)) {
|
||||
if (!\is_int($result)) {
|
||||
Log::error(sprintf('Result of verification is a boolean (%d), return false.', $result));
|
||||
|
||||
return false;
|
||||
|
||||
@@ -43,7 +43,6 @@ class DeleteDeviceSessionRequest extends BunqRequest
|
||||
$headers['X-Bunq-Client-Authentication'] = $this->sessionToken->getToken();
|
||||
$this->sendSignedBunqDelete($uri, $headers);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -55,8 +55,6 @@ class DeviceServerRequest extends BunqRequest
|
||||
$deviceServerId = new DeviceServerId;
|
||||
$deviceServerId->setId((int)$response['Response'][0]['Id']['id']);
|
||||
$this->deviceServerId = $deviceServerId;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -61,7 +61,6 @@ class DeviceSessionRequest extends BunqRequest
|
||||
$this->userPerson = $this->extractUserPerson($response);
|
||||
$this->userCompany = $this->extractUserCompany($response);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -58,7 +58,7 @@ class ListDeviceServerRequest extends BunqRequest
|
||||
Log::debug('Returned from sending device-server list request!');
|
||||
// create device server objects:
|
||||
$raw = $this->getArrayFromResponse('DeviceServer', $response);
|
||||
Log::debug(sprintf('Count %d entries in response array.', count($raw)));
|
||||
Log::debug(sprintf('Count %d entries in response array.', \count($raw)));
|
||||
Log::debug('Full response', $response);
|
||||
/** @var array $entry */
|
||||
foreach ($raw as $entry) {
|
||||
@@ -67,7 +67,6 @@ class ListDeviceServerRequest extends BunqRequest
|
||||
$this->devices->push($server);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -57,7 +57,6 @@ class ListMonetaryAccountRequest extends BunqRequest
|
||||
$this->monetaryAccounts->push($account);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -70,7 +70,6 @@ class ListPaymentRequest extends BunqRequest
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -59,7 +59,6 @@ class ListUserRequest extends BunqRequest
|
||||
$this->userCompany = new UserCompany($company);
|
||||
$this->userPerson = new UserPerson($person);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user