Skip to content

Commit 76a8776

Browse files
committed
Improve typing
1 parent 8c403f1 commit 76a8776

File tree

8 files changed

+36
-15
lines changed

8 files changed

+36
-15
lines changed

src/Informat/AccessToken/AccessTokenFetcher.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ public function fetch(): AccessToken
3939

4040
$response = $this->httpClient->sendRequest($request);
4141
if ($response->getStatusCode() !== 200) {
42-
throw new AccessTokenException('Fetching access token failed.');
42+
throw new AccessTokenException(
43+
'Fetching access token failed.',
44+
$this->scopeStrategy->getScopes()
45+
);
4346
}
4447

4548
$decoded = json_decode(
@@ -55,6 +58,9 @@ public function fetch(): AccessToken
5558
return new AccessToken($decoded['access_token'], $decoded['expires_in']);
5659
}
5760

58-
throw new AccessTokenException('Invalid access token');
61+
throw new AccessTokenException(
62+
'Invalid access token',
63+
$this->scopeStrategy->getScopes()
64+
);
5965
}
6066
}

src/Informat/Exceptions/AccessTokenException.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,19 @@
44

55
class AccessTokenException extends InformatException
66
{
7+
/**
8+
* @param string[] $scopes
9+
*/
10+
public function __construct(string $message, protected array $scopes)
11+
{
12+
parent::__construct($message);
13+
}
14+
15+
/**
16+
* @return string[]
17+
*/
18+
public function getScopes(): array
19+
{
20+
return $this->scopes;
21+
}
722
}

src/Informat/Responses/Personnel/Address.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Address
2626
public string $postcode;
2727

2828
/** Submunicipality. */
29-
public string $gemeente;
29+
public ?string $gemeente;
3030

3131
/** Official country code. */
3232
public string $landCode;

src/Informat/Responses/Personnel/Ambt.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
class Ambt
66
{
77
/** Code of employee’s main function. */
8-
public string $code;
8+
public ?string $code;
99

1010
/** Description of employee’s main function. */
11-
public string $naam;
11+
public ?string $naam;
1212
}

src/Informat/Responses/Personnel/Bank.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ class Bank
1111
* Employee’s Bank Identification Code.
1212
* Format: 8 to 11 characters if provided.
1313
*/
14-
public string $bic;
14+
public ?string $bic;
1515
}

src/Informat/Responses/Personnel/Child.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Child
2020
public Sex $geslacht;
2121

2222
/** Child’s date of birth. */
23-
public string $geboortedatum;
23+
public ?DateTime $geboortedatum;
2424

2525
/** Indicates whether the child is deceased. */
2626
public bool $isOverleden;

src/Informat/Responses/Personnel/Employee.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ class Employee
2424
public string $voornaam;
2525

2626
/** Employee’s additional names. */
27-
public string $bijkomendeVoornamen;
27+
public ?string $bijkomendeVoornamen;
2828

2929
/**
3030
* Employee’s stamnummer.
3131
* Format: 11 characters (digits)
3232
*/
33-
public string $stamnr;
33+
public ?string $stamnr;
3434

3535
/** Employee’s sortable name. */
3636
public string $sortName;
@@ -42,25 +42,25 @@ class Employee
4242
public Sex $geslacht;
4343

4444
/** Employee’s initials. */
45-
public string $initialen;
45+
public ?string $initialen;
4646

4747
/** Employee’s date of birth. */
4848
public DateTime $geboortedatum;
4949

5050
/** Employee’s place of birth. */
51-
public string $geboorteplaats;
51+
public ?string $geboorteplaats;
5252

5353
/** Employee’s official country of birth code. */
5454
public string $geboortelandCode;
5555

5656
/** Employee’s official nationality code. */
57-
public string $nationaliteitCode;
57+
public ?string $nationaliteitCode;
5858

5959
/**
6060
* Employee’s national registration number for Belgium residents.
6161
* Format: ”yymmddxxxxx” if provided
6262
*/
63-
public string $rijksregisternr;
63+
public ?string $rijksregisternr;
6464

6565
/**
6666
* Employee’s national registration number for a foreign person.
@@ -109,7 +109,7 @@ class Employee
109109
public ?DateTime $datumOverleden;
110110

111111
/** Employee’s civil status. */
112-
public BurgerlijkeStand $burgStand;
112+
public ?BurgerlijkeStand $burgStand;
113113

114114
/** Single object representing employee’s partner. */
115115
public ?Partner $partner;

src/Informat/Responses/Personnel/Partner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Partner
1414
public string $naam;
1515

1616
/** Partner’s first name. */
17-
public string $voornaam;
17+
public ?string $voornaam;
1818

1919
/** Partner’s date of birth. */
2020
public ?DateTime $geboortedatum;

0 commit comments

Comments
 (0)