note 99552 deleted from function.isset by danbrown
| From: | danbrown@php.net | Date: | Tue, 24 Aug 2010 12:47:18 +0000 |
| Subject: | note 99552 deleted from function.isset by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-171970@lists.php.net to get a copy of this message | ||
Note Submitter: dominic dot fox at gmail dot com
----
<?php
// Usage: maybe($a)->otherwise($b)
// maybe($a)->orMaybe($b)->otherwise($c)
class Maybe {
private $value;
public function __construct($value) {
$this->value = $value;
}
public function orMaybe($value) {
return isset($this->value) ? $this : new Maybe($value);
}
public function otherwise($default=false) {
return isset($this->value) ? $this->value : $default;
}
}
function maybe($a) {
return new Maybe($a);
}
?>