Skip to content

Commit 48082c5

Browse files
committed
Fix code style with PHP-CS-Fixer
1 parent ec88a81 commit 48082c5

11 files changed

Lines changed: 49 additions & 38 deletions

File tree

.php-cs-fixer.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
// This is based on the `@Symfony` rule set documented in `vendor/friendsofphp/php-cs-fixer/doc/ruleSets/Symfony.rst`.
44

55
$finder = PhpCsFixer\Finder::create()
6-
->in(__DIR__ . '/lib');
6+
->in([
7+
__DIR__ . '/lib',
8+
__DIR__ . '/Tests',
9+
]);
710

811
return (new PhpCsFixer\Config())
912
->setRules([

Tests/Unit/FinTsTestCase.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,8 @@ protected function setUpConnection()
103103
+ strlen($mockMiddle) + strlen($hnvsd) + strlen($mockSuffix);
104104
$newLength = str_pad($newLength, HNHBKv3::NACHRICHTENGROESSE_LENGTH, '0', STR_PAD_LEFT);
105105
return $mockPrefix . $newLength . $mockMiddle . $hnvsd . $mockSuffix;
106-
} else {
107-
return $mockResponse;
108106
}
107+
return $mockResponse;
109108
});
110109
return $this->connection;
111110
}

lib/Fhp/FinTs.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ public function execute(BaseAction $action): void
346346
$message = MessageBuilder::create()->add($requestSegments);
347347

348348
// Add HKTAN for authentication if necessary.
349-
if (!($this->getSelectedTanMode() instanceof NoPsd2TanMode)) {
349+
if (!$this->getSelectedTanMode() instanceof NoPsd2TanMode) {
350350
if (($needTanForSegment = $action->getNeedTanForSegment()) !== null) {
351351
$message->add(HKTANFactory::createProzessvariante2Step1(
352352
$this->requireTanMode(), $this->selectedTanMedium, $needTanForSegment));
@@ -421,11 +421,10 @@ private function processServerResponse(BaseAction $action, Message $response, ?H
421421
if ($confirmationRequest->getVerificationResult() === VopVerificationResult::CompletedFullMatch) {
422422
// If someone hits this branch in practice, we can implement it.
423423
throw new UnsupportedException('Combined VOP match confirmation and TAN request');
424-
} else {
425-
throw new UnexpectedResponseException(
426-
'Unexpected TAN request on VOP result: ' . $confirmationRequest->getVerificationResult()
427-
);
428424
}
425+
throw new UnexpectedResponseException(
426+
'Unexpected TAN request on VOP result: ' . $confirmationRequest->getVerificationResult()
427+
);
429428
}
430429
}
431430
}
@@ -684,7 +683,7 @@ public function pollAction(BaseAction $action): void
684683
public function confirmVop(BaseAction $action): void
685684
{
686685
$vopConfirmationRequest = $action->getVopConfirmationRequest();
687-
if (!($vopConfirmationRequest instanceof VopConfirmationRequestImpl)) {
686+
if (!$vopConfirmationRequest instanceof VopConfirmationRequestImpl) {
688687
throw new \InvalidArgumentException('Unexpected type: ' . gettype($vopConfirmationRequest));
689688
}
690689
// We need to send the original request again, plus HKVPA as the confirmation.
@@ -697,7 +696,7 @@ public function confirmVop(BaseAction $action): void
697696
->add(VopHelper::createHKVPAForConfirmation($vopConfirmationRequest));
698697

699698
// Add HKTAN for authentication if necessary.
700-
if (!($this->getSelectedTanMode() instanceof NoPsd2TanMode)) {
699+
if (!$this->getSelectedTanMode() instanceof NoPsd2TanMode) {
701700
if (($needTanForSegment = $action->getNeedTanForSegment()) !== null) {
702701
$message->add(HKTANFactory::createProzessvariante2Step1(
703702
$this->requireTanMode(), $this->selectedTanMedium, $needTanForSegment));
@@ -930,7 +929,7 @@ private function ensureSynchronized(): void
930929
// banks that don't support PSD2, we just keep the dummy TAN mode, as they wouldn't even understand 999.
931930
$oldTanMode = $this->selectedTanMode;
932931
$oldTanMedium = $this->selectedTanMedium;
933-
if (!($this->selectedTanMode instanceof NoPsd2TanMode)) {
932+
if (!$this->selectedTanMode instanceof NoPsd2TanMode) {
934933
$this->selectedTanMode = null;
935934
}
936935
$this->selectedTanMedium = null;

lib/Fhp/Model/StatementOfAccount/Transaction.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,8 @@ public function getMainDescription(): string
254254
{
255255
if (array_key_exists('SVWZ', $this->structuredDescription)) {
256256
return $this->structuredDescription['SVWZ'];
257-
} else {
258-
return '';
259257
}
258+
return '';
260259
}
261260

262261
/**
@@ -266,9 +265,8 @@ public function getEndToEndID(): string
266265
{
267266
if (array_key_exists('EREF', $this->structuredDescription)) {
268267
return $this->structuredDescription['EREF'];
269-
} else {
270-
return '';
271268
}
269+
return '';
272270
}
273271

274272
/**

lib/Fhp/Protocol/BPD.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function getBankName()
8585
public function getAllSupportedParameters(string $type): array
8686
{
8787
return array_filter($this->parameters[$type] ?? [], function (BaseSegment $segment) {
88-
return !($segment instanceof AnonymousSegment);
88+
return !$segment instanceof AnonymousSegment;
8989
});
9090
}
9191

@@ -101,7 +101,7 @@ public function getLatestSupportedParameters(string $type): ?BaseSegment
101101
return null;
102102
}
103103
foreach ($this->parameters[$type] as $segment) {
104-
if (!($segment instanceof AnonymousSegment)) {
104+
if (!$segment instanceof AnonymousSegment) {
105105
return $segment;
106106
}
107107
}

lib/Fhp/Protocol/Message.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,19 +320,19 @@ public static function parse(string $rawMessage): Message
320320
// Message header and footer must always be there, or something went badly wrong.
321321
$result->header = $segments[0];
322322
$result->footer = $segments[count($segments) - 1];
323-
if (!($result->header instanceof HNHBKv3)) {
323+
if (!$result->header instanceof HNHBKv3) {
324324
$actual = $result->header->getName();
325325
throw new \InvalidArgumentException("Expected first segment to be HNHBK, but got $actual: $rawMessage");
326326
}
327-
if (!($result->footer instanceof HNHBSv1)) {
327+
if (!$result->footer instanceof HNHBSv1) {
328328
$actual = $result->footer->getName();
329329
throw new \InvalidArgumentException("Expected last segment to be HNHBS, but got $actual: $rawMessage");
330330
}
331331

332332
// Check if there's an encryption header and "encrypted" data.
333333
// Section B.8 specifies that there are exactly 4 segments: HNHBK, HNVSK, HNVSD, HNHBS.
334334
if (count($segments) === 4 && $segments[1] instanceof HNVSKv3) {
335-
if (!($segments[2] instanceof HNVSDv1)) {
335+
if (!$segments[2] instanceof HNVSDv1) {
336336
throw new \InvalidArgumentException("Expected third segment to be HNVSD: $rawMessage");
337337
}
338338
$result->wrapperSegments = $segments;

lib/Fhp/Segment/BaseSegment.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,9 @@ public static function parse(string $rawSegment): static
123123
if (static::class === BaseSegment::class) {
124124
// Called as BaseSegment::parse(), so we need to determine the right segment type/class.
125125
return Parser::detectAndParseSegment($rawSegment);
126-
} else {
127-
// The parse() function was called on the segment subclass itself.
128-
return Parser::parseSegment($rawSegment, static::class);
129126
}
127+
// The parse() function was called on the segment subclass itself.
128+
return Parser::parseSegment($rawSegment, static::class);
130129
}
131130

132131
/**

lib/Fhp/Segment/Common/Sdo.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ public function getAmount(): float
3636
{
3737
if ($this->sollHabenKennzeichen === self::CREDIT) {
3838
return $this->betrag->wert;
39-
} elseif ($this->sollHabenKennzeichen === self::DEBIT) {
39+
}
40+
41+
if ($this->sollHabenKennzeichen === self::DEBIT) {
4042
return -1 * $this->betrag->wert;
41-
} else {
42-
throw new \InvalidArgumentException("Invalid sollHabenKennzeichen: $this->sollHabenKennzeichen");
4343
}
44+
45+
throw new \InvalidArgumentException("Invalid sollHabenKennzeichen: $this->sollHabenKennzeichen");
4446
}
4547

4648
public function getCurrency(): string

lib/Fhp/Segment/SegmentDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected function __construct(string $class)
5454
public function validateObject($obj): void // Override
5555
{
5656
parent::validateObject($obj);
57-
if (!($obj instanceof BaseSegment)) {
57+
if (!$obj instanceof BaseSegment) {
5858
throw new \InvalidArgumentException('Expected sub-class of BaseSegment, got ' . gettype($obj));
5959
}
6060
if ($obj->getName() !== $this->kennung) {

lib/Fhp/Syntax/Parser.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,11 +427,13 @@ private static function parseSegmentElement(string $rawElement, ElementDescripto
427427
{
428428
if (is_string($descriptor->type)) { // Scalar value / DE
429429
return static::parseDataElement($rawElement, $descriptor->type);
430-
} elseif ($descriptor->type->getName() === Bin::class) {
430+
}
431+
432+
if ($descriptor->type->getName() === Bin::class) {
431433
return static::parseBinaryBlock($rawElement);
432-
} else {
433-
return static::parseDeg($rawElement, $descriptor->type->name, $descriptor->optional);
434434
}
435+
436+
return static::parseDeg($rawElement, $descriptor->type->name, $descriptor->optional);
435437
}
436438

437439
/**

0 commit comments

Comments
 (0)