Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ This ensures absolute reliability and alignment with the Java specification.
```php
use PetrKnap\Optional\Optional;

// Create string option which holds data
$stringOption = Optional::of('data');
if ($stringOption->isPresent()) {
echo $stringOption->get();
}
// Print data from string option
echo $stringOption->orElse('missing data');

// Handle function that returns false on failure
Optional::ofFalsable(tmpfile())->ifPresent(function ($tmpFile): void {
fwrite($tmpFile, 'data');
fclose($tmpFile);
Expand Down
4 changes: 2 additions & 2 deletions src/Optional.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function flatMap(callable $mapper): JavaSe8\Optional
}

/**
* @see self::orElseThrow() - more explicit alternative
* @deprecated Not recommended; use {@see self::orElseThrow()} instead.
*/
public function get(): mixed
{
Expand All @@ -187,7 +187,7 @@ public function ifPresent(callable $consumer, callable|null $else = null): void
}

/**
* @see self::ifPresent() - shorter alternative
* @deprecated Not recommended; use {@see self::ifPresent()} instead.
*/
public function ifPresentOrElse(callable $action, callable $emptyAction): void
{
Expand Down
Loading