File tree 2 files changed +25
-0
lines changed
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
26
26
return new self ($ str );
27
27
}
28
28
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
+
29
39
/**
30
40
* Class constructor.
31
41
*
Original file line number Diff line number Diff line change @@ -51,6 +51,21 @@ public static function empty(): self
51
51
return self ::$ empty ;
52
52
}
53
53
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
+
54
69
/**
55
70
* Creates an nullable Optional given a return value.
56
71
*
You can’t perform that action at this time.
0 commit comments