Skip to content

Commit c5d2e3f

Browse files
committed
Move types to properties for common segment classes
1 parent 94e52d9 commit c5d2e3f

File tree

10 files changed

+55
-69
lines changed

10 files changed

+55
-69
lines changed

lib/Fhp/Segment/Common/AccountInfo.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
*/
88
interface AccountInfo
99
{
10-
/** @return string This is the IBAN, if available, or the plain account number otherwise. */
11-
public function getAccountNumber();
10+
/** This is the IBAN, if available, or the plain account number otherwise. */
11+
public function getAccountNumber(): string;
1212

13-
/** @return string|null This is the BIC, if available, or the country-specific bank code otherwise. */
14-
public function getBankIdentifier();
13+
/** This is the BIC, if available, or the country-specific bank code otherwise. */
14+
public function getBankIdentifier(): ?string;
1515
}

lib/Fhp/Segment/Common/Btg.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99
*/
1010
class Btg extends BaseDeg
1111
{
12-
/** @var float */
13-
public $wert;
14-
/** @var string */
15-
public $waehrung;
12+
public float $wert;
13+
public string $waehrung;
1614

17-
public static function create(float $wert, string $waehrung = 'EUR')
15+
public static function create(float $wert, string $waehrung = 'EUR'): Btg
1816
{
1917
$result = new Btg();
2018
$result->wert = $wert;

lib/Fhp/Segment/Common/Kik.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ class Kik extends BaseDeg
1414
{
1515
public const DEFAULT_COUNTRY_CODE = '280'; // Germany
1616

17-
/** @var string (ISO 3166-1; has leading zeros; Germany is 280, see also chapter E.4 */
18-
public $laenderkennzeichen;
19-
/** @var string|null Max length: 30 (Mandatory/absent depending on the country) */
20-
public $kreditinstitutscode;
17+
/** (ISO 3166-1; has leading zeros; Germany is 280, see also chapter E.4 */
18+
public ?string $laenderkennzeichen; // Officially it's mandatory, but in practice it can be missing.
19+
/** Max length: 30 (Mandatory/absent depending on the country) */
20+
public ?string $kreditinstitutscode = null;
2121

2222
/** {@inheritdoc} */
2323
public function validate()

lib/Fhp/Segment/Common/Kti.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,17 @@
1414
*/
1515
class Kti extends BaseDeg implements AccountInfo
1616
{
17-
/** @var string|null Max length: 34 */
18-
public $iban;
19-
/** @var string|null Max length: 11, required if IBAN is present. */
20-
public $bic;
17+
/** Max length: 34 */
18+
public ?string $iban = null;
19+
/** Max length: 11, required if IBAN is present. */
20+
public ?string $bic = null;
2121

2222
// The following fields can only be set if the BPD parameters allow it. If they are set, the fields above become
2323
// optional.
24-
/** @var string|null Also known as Depotnummer. */
25-
public $kontonummer;
26-
/** @var string|null */
27-
public $unterkontomerkmal;
28-
/** @var Kik|null */
29-
public $kreditinstitutskennung;
24+
/** Also known as Depotnummer. */
25+
public ?string $kontonummer = null;
26+
public ?string $unterkontomerkmal = null;
27+
public ?Kik $kreditinstitutskennung = null;
3028

3129
/** {@inheritdoc} */
3230
public function validate()
@@ -61,13 +59,13 @@ public static function fromAccount(SEPAAccount $account): Kti
6159
}
6260

6361
/** {@inheritdoc} */
64-
public function getAccountNumber()
62+
public function getAccountNumber(): string
6563
{
6664
return $this->iban ?? $this->kontonummer;
6765
}
6866

6967
/** {@inheritdoc} */
70-
public function getBankIdentifier()
68+
public function getBankIdentifier(): ?string
7169
{
7270
return $this->bic ?? $this->kreditinstitutskennung->kreditinstitutscode;
7371
}

lib/Fhp/Segment/Common/Kto.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515
*/
1616
class Kto extends BaseDeg implements AccountInfo
1717
{
18-
/** @var string */
19-
public $kontonummer; // Aka Depotnummer
20-
/** @var Kik */
21-
public $kik;
18+
public string $kontonummer; // Aka Depotnummer
19+
public Kik $kik;
2220

2321
public static function create(string $kontonummer, Kik $kik): Kto
2422
{
@@ -34,13 +32,13 @@ public static function fromAccount(SEPAAccount $account): Kto
3432
}
3533

3634
/** {@inheritdoc} */
37-
public function getAccountNumber()
35+
public function getAccountNumber(): string
3836
{
3937
return $this->kontonummer;
4038
}
4139

4240
/** {@inheritdoc} */
43-
public function getBankIdentifier()
41+
public function getBankIdentifier(): ?string
4442
{
4543
return $this->kik->kreditinstitutscode;
4644
}

lib/Fhp/Segment/Common/KtvV3.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,9 @@
1919
*/
2020
class KtvV3 extends BaseDeg implements AccountInfo
2121
{
22-
/** @var string */
23-
public $kontonummer;
24-
/** @var string|null */
25-
public $unterkontomerkmal;
26-
/** @var Kik */
27-
public $kik;
22+
public ?string $kontonummer = null; // Officially it's mandatory, but in practice it can be missing.
23+
public ?string $unterkontomerkmal = null;
24+
public ?Kik $kik = null; // Officially it's mandatory, but in practice it can be missing.
2825

2926
public static function create(string $kontonummer, ?string $unterkontomerkmal, Kik $kik): KtvV3
3027
{
@@ -41,13 +38,13 @@ public static function fromAccount(SEPAAccount $account): KtvV3
4138
}
4239

4340
/** {@inheritdoc} */
44-
public function getAccountNumber()
41+
public function getAccountNumber(): string
4542
{
46-
return $this->kontonummer;
43+
return $this->kontonummer ?: '';
4744
}
4845

4946
/** {@inheritdoc} */
50-
public function getBankIdentifier()
47+
public function getBankIdentifier(): ?string
5148
{
5249
return $this->kik->kreditinstitutscode;
5350
}

lib/Fhp/Segment/Common/Ktz.php

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,25 @@
1313
*/
1414
class Ktz extends BaseDeg implements AccountInfo
1515
{
16-
/** @var bool Whether it's a SEPA account that has IBAN/BIC, or not (e.g. a stock depot) */
17-
public $kontoverwendungSepa;
18-
/** @var string|null Max length: 34 */
19-
public $iban;
20-
/** @var string|null Max length: 11, required if IBAN is present. */
21-
public $bic;
22-
/** @var string Also known as Depotnummer. */
23-
public $kontonummer;
24-
/** @var string|null */
25-
public $unterkontomerkmal;
26-
/** @var Kik */
27-
public $kreditinstitutskennung;
16+
/** Whether it's a SEPA account that has IBAN/BIC, or not (e.g. a stock depot) */
17+
public bool $kontoverwendungSepa;
18+
/** Max length: 34 */
19+
public ?string $iban = null;
20+
/** Max length: 11, required if IBAN is present. */
21+
public ?string $bic = null;
22+
/** Also known as Depotnummer. */
23+
public string $kontonummer;
24+
public ?string $unterkontomerkmal = null;
25+
public Kik $kreditinstitutskennung;
2826

2927
/** {@inheritdoc} */
30-
public function getAccountNumber()
28+
public function getAccountNumber(): string
3129
{
3230
return $this->iban ?? $this->kontonummer;
3331
}
3432

3533
/** {@inheritdoc} */
36-
public function getBankIdentifier()
34+
public function getBankIdentifier(): ?string
3735
{
3836
return $this->bic ?? $this->kreditinstitutskennung->kreditinstitutscode;
3937
}

lib/Fhp/Segment/Common/Kursqualitaet.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@ class Kursqualitaet extends BaseDeg
1515
public const DELAYED = 1; // delayed-Kurs
1616
public const REALTIME = 2; // Echtzeit-Kurs
1717

18-
/** @var int */
19-
public $kursqualitaet;
18+
public int $kursqualitaet;
2019
}

lib/Fhp/Segment/Common/Sdo.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,13 @@ class Sdo extends BaseDeg
2424
* Allowed values:
2525
* "C" = Credit (the signum of $wert is positive)
2626
* "D" = Debit (the signum of $wert is negative)
27-
* @var string
2827
*/
29-
public $sollHabenKennzeichen;
30-
/** @var Btg */
31-
public $betrag;
32-
/** @var string JJJJMMTT gemäß ISO 8601 */
33-
public $datum;
34-
/** @var string|null hhmmss gemäß ISO 8601, local time (no time zone support). */
35-
public $uhrzeit;
28+
public string $sollHabenKennzeichen;
29+
public Btg $betrag;
30+
/** JJJJMMTT gemäß ISO 8601 */
31+
public string $datum;
32+
/** hhmmss gemäß ISO 8601, local time (no time zone support). */
33+
public ?string $uhrzeit = null;
3634

3735
public function getAmount(): float
3836
{
@@ -55,7 +53,7 @@ public function getTimestamp(): \DateTime
5553
return \DateTime::createFromFormat('Ymd His', $this->datum . ' ' . ($this->uhrzeit ?? '000000'));
5654
}
5755

58-
public static function create(float $amount, string $currency, \DateTime $timestamp)
56+
public static function create(float $amount, string $currency, \DateTime $timestamp): Sdo
5957
{
6058
$result = new Sdo();
6159
$result->sollHabenKennzeichen = $amount < 0 ? self::DEBIT : self::CREDIT;

lib/Fhp/Segment/Common/Tsp.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
*/
1313
class Tsp extends BaseDeg
1414
{
15-
/** @var string JJJJMMTT gemäß ISO 8601 */
16-
public $datum;
17-
/** @var string|null hhmmss gemäß ISO 8601, local time (no time zone support). */
18-
public $uhrzeit;
15+
/** JJJJMMTT gemäß ISO 8601 */
16+
public string $datum;
17+
/** hhmmss gemäß ISO 8601, local time (no time zone support). */
18+
public ?string $uhrzeit = null;
1919

2020
public static function create(string $datum, ?string $uhrzeit): Tsp
2121
{

0 commit comments

Comments
 (0)