This method has been deprecated. Use forAll() instead.
Option::ifDefined( callable $callable )
This is similar to map() below except that the return value has no meaning; the passed callable is simply executed if the option is non-empty, and ignored if the option is empty.
Description
In all cases, the return value of the callable is discarded.
$comment->getMaybeFile()->ifDefined(function($file) { // Do something with $file here. });
If you’re looking for something like ifEmpty
, you can use getOrCall
and getOrElse
in these cases.
Parameters
- $callable
-
(Required)
Return
(void)
Source
File: vendor/phpoption/phpoption/src/PhpOption/Option.php
abstract public function ifDefined($callable);