Skip to content

Commit

Permalink
isBool() -> asBool()
Browse files Browse the repository at this point in the history
  • Loading branch information
faissaloux committed Mar 30, 2024
1 parent 91d345e commit 98cc39d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function asInt(): int
/**
* Asserts and narrow down the type to boolean.
*/
public function isBool(): bool
public function asBool(): bool
{
if (! is_bool($this->variable)) {
throw new TypeError('Variable is not a boolean.');
Expand Down
4 changes: 2 additions & 2 deletions tests/IsBoolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
test('boolean type', function () {
$variable = true;

$value = type($variable)->isBool();
$value = type($variable)->asBool();

expect($value)->toBeBool();
});

test('not boolean type', function () {
$variable = 7415541;

type($variable)->isBool();
type($variable)->asBool();
})->throws(TypeError::class, 'Variable is not a boolean.');

0 comments on commit 98cc39d

Please sign in to comment.