Skip to content

Commit

Permalink
remove unused imports and fix variable use
Browse files Browse the repository at this point in the history
  • Loading branch information
0xfrej committed Oct 27, 2024
1 parent 0ae19db commit 0da08ac
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
namespace Frej\Optional;

use Frej\Optional\Exception\OptionNoneUnwrappedException;
use Option as OptionOption;
use PharIo\Manifest\Url;

use function PHPUnit\Framework\returnSelf;

/**
* Class Option
Expand Down Expand Up @@ -121,9 +117,9 @@ public function unwrap(): mixed
}

/**
* Retrieve the wrapped value or the value passed as fallback
* Retrieve the wrapped value or the value passed as default
*
* @param T|callable(): T $fallback fallback Value to be used as fallback when option is not Some. When callable is provided, it will be called to resolve the fallback value instead.
* @param T|callable(): T $default Value to be used as fallback when option is not Some. When callable is provided, it will be called to resolve the fallback value instead.
* @return T
*/
public function unwrapOr(mixed $default): mixed
Expand All @@ -132,10 +128,10 @@ public function unwrapOr(mixed $default): mixed
return $this->val;
}

if (is_callable($fallback)) {
return $fallback();
if (is_callable($default)) {
return $default();
}
return $fallback;
return $default;
}

/**
Expand Down

0 comments on commit 0da08ac

Please sign in to comment.