Skip to content

Commit be10fa5

Browse files
committed
Preparing for 8.3+
1 parent 39ff2f0 commit be10fa5

5 files changed

Lines changed: 12 additions & 25 deletions

File tree

src/BCMathService.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class BCMathService implements ServiceInterface
2424
* @param string $alphabet optional
2525
* @since v1.1.0
2626
*/
27-
public function __construct($alphabet = null)
27+
public function __construct(?string $alphabet = null)
2828
{
2929
// Handle null alphabet
3030
if (is_null($alphabet) === true) {
@@ -51,7 +51,7 @@ public function __construct($alphabet = null)
5151
* @since Release v1.1.0
5252
* @return string The Base58 encoded string.
5353
*/
54-
public function encode($string)
54+
public function encode(string $string) : string
5555
{
5656
// Type validation
5757
if (is_string($string) === false) {
@@ -113,7 +113,7 @@ public function encode($string)
113113
* @since Release v1.1.0
114114
* @return string Returns the decoded string.
115115
*/
116-
public function decode($base58)
116+
public function decode(string $base58) : string
117117
{
118118
// Type Validation
119119
if (is_string($base58) === false) {

src/Base58.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,14 @@ class Base58
2929
* @since v1.1.0 Added the optional $service argument.
3030
*/
3131
public function __construct(
32-
$alphabet = null,
33-
ServiceInterface $service = null
32+
?string $alphabet = null,
33+
?ServiceInterface $service = null
3434
) {
3535
// Handle null alphabet
3636
if (is_null($alphabet) === true) {
3737
$alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
3838
}
3939

40-
// Type validation
41-
if (is_string($alphabet) === false) {
42-
throw new InvalidArgumentException('Argument $alphabet must be a string.');
43-
}
44-
4540
// The alphabet must contain 58 characters
4641
if (strlen($alphabet) !== 58) {
4742
throw new InvalidArgumentException('Argument $alphabet must contain 58 characters.');
@@ -71,7 +66,7 @@ public function __construct(
7166
* @since v1.0.0
7267
* @return string The Base58 encoded string.
7368
*/
74-
public function encode($string)
69+
public function encode(string $string) : string
7570
{
7671
return $this->service->encode($string);
7772
}
@@ -83,7 +78,7 @@ public function encode($string)
8378
* @since v1.0.0
8479
* @return string Returns the decoded string.
8580
*/
86-
public function decode($base58)
81+
public function decode(string $base58) : string
8782
{
8883
return $this->service->decode($base58);
8984
}

src/GMPService.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class GMPService implements ServiceInterface
2424
* @param string $alphabet optional
2525
* @since v1.1.0
2626
*/
27-
public function __construct($alphabet = null)
27+
public function __construct(?string $alphabet = null)
2828
{
2929
// Handle null alphabet
3030
if (is_null($alphabet) === true) {
@@ -51,7 +51,7 @@ public function __construct($alphabet = null)
5151
* @since Release v1.1.0
5252
* @return string The Base58 encoded string.
5353
*/
54-
public function encode($string)
54+
public function encode(string $string) : string
5555
{
5656
// Type validation
5757
if (is_string($string) === false) {
@@ -105,7 +105,7 @@ public function encode($string)
105105
* @since Release v1.1.0
106106
* @return string Returns the decoded string.
107107
*/
108-
public function decode($base58)
108+
public function decode(string $base58) : string
109109
{
110110
// Type Validation
111111
if (is_string($base58) === false) {

src/ServiceInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ interface ServiceInterface
1111
* @since v1.1.0
1212
* @return string The Base58 encoded string.
1313
*/
14-
public function encode($string);
14+
public function encode(string $string) : string;
1515

1616
/**
1717
* Decode base58 into a PHP string.
@@ -20,5 +20,5 @@ public function encode($string);
2020
* @since v1.1.0
2121
* @return string Returns the decoded string.
2222
*/
23-
public function decode($base58);
23+
public function decode(string $base58) : string;
2424
}

tests/Base58Test.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,6 @@ public static function encodingsProvider(): array
5656
return $return;
5757
}
5858

59-
public function testConstructorTypeException(): void
60-
{
61-
$this->expectException(\InvalidArgumentException::class);
62-
$this->expectExceptionMessage('Argument $alphabet must be a string.');
63-
64-
new Base58(intval(123));
65-
}
66-
6759
public function testConstructorLengthException(): void
6860
{
6961
$this->expectException(\InvalidArgumentException::class);

0 commit comments

Comments
 (0)