File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,16 @@ public static function new(string $str): self
2626 return new self ($ str );
2727 }
2828
29+ /**
30+ * @param string $str
31+ *
32+ * @return self
33+ */
34+ public static function newTrim (string $ str ): self
35+ {
36+ return new self (trim ($ str ));
37+ }
38+
2939 /**
3040 * Class constructor.
3141 *
Original file line number Diff line number Diff line change @@ -51,6 +51,21 @@ public static function empty(): self
5151 return self ::$ empty ;
5252 }
5353
54+ /**
55+ * Creates an nullable Optional given a return value.
56+ * - value assert by `empty` function.
57+ *
58+ * @template S
59+ *
60+ * @param S $value
61+ *
62+ * @return static
63+ */
64+ public static function ofEmptyAble (mixed $ value ): self
65+ {
66+ return empty ($ value ) ? self ::empty () : self ::of ($ value );
67+ }
68+
5469 /**
5570 * Creates an nullable Optional given a return value.
5671 *
You can’t perform that action at this time.
0 commit comments