@@ -18,6 +18,10 @@ class Str
1818 */
1919 public static function camel ($ subject )
2020 {
21+ if ($ subject === null ) {
22+ return '' ;
23+ }
24+
2125 $ normalized = str_replace (['- ' , '_ ' ], ' ' , $ subject );
2226
2327 return lcfirst (str_replace (' ' , '' , ucwords (strtolower ($ normalized ))));
@@ -32,8 +36,9 @@ public static function camel($subject)
3236 *
3337 * @return bool
3438 */
35- public static function startsWith ($ subject , $ start , $ caseSensitive = true )
39+ public static function startsWith ($ subject , string $ start , bool $ caseSensitive = true )
3640 {
41+ $ subject = $ subject ?? '' ;
3742 if (! $ caseSensitive ) {
3843 return strncasecmp ($ subject , $ start , strlen ($ start )) === 0 ;
3944 }
@@ -53,8 +58,12 @@ public static function startsWith($subject, $start, $caseSensitive = true)
5358 *
5459 * @return array
5560 */
56- public static function symmetricSplit ($ subject , $ delimiter , $ limit , $ default = null )
61+ public static function symmetricSplit ($ subject , string $ delimiter , int $ limit , $ default = null )
5762 {
63+ if ($ subject === null ) {
64+ return [];
65+ }
66+
5867 return array_pad (explode ($ delimiter , $ subject , $ limit ), $ limit , $ default );
5968 }
6069
@@ -67,8 +76,12 @@ public static function symmetricSplit($subject, $delimiter, $limit, $default = n
6776 *
6877 * @return array
6978 */
70- public static function trimSplit ($ subject , $ delimiter = ', ' , $ limit = null )
79+ public static function trimSplit ($ subject , string $ delimiter = ', ' , int $ limit = null )
7180 {
81+ if ($ subject === null ) {
82+ return [];
83+ }
84+
7285 if ($ limit !== null ) {
7386 $ exploded = explode ($ delimiter , $ subject , $ limit );
7487 } else {
0 commit comments