Skip to content

Commit 711c778

Browse files
committed
Add default string placeholder and Add some Doc Blocks
1 parent 5143d8a commit 711c778

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/Nuller.php

+24-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@
33

44
Class Nuller {
55

6+
7+
/**
8+
* @var string The default string placeholder
9+
*/
10+
public static $default_string_placeholder = 'Null';
11+
612
/**
7-
* @param $string String to be nulled
13+
* Nullified String
14+
*
15+
* @param $string String to be nullified
816
* @param bool|false $as_string returns desired string value if true
917
* @param string $display_string String to be returned if as_string is true
1018
* @return null|string
@@ -13,10 +21,24 @@ public static function nullified($string, $as_string = false, $display_string =
1321
return $as_string ? self::nullifiedToString($string, $display_string) : null;
1422
}
1523

24+
/**
25+
* Nullified to Desired String Placeholder
26+
*
27+
* @param $string String to be nullified
28+
* @param string $display_string String to replace as placeholder
29+
* @return string
30+
*/
1631
public static function nullifiedToString($string, $display_string = '') {
17-
return $display_string ?: 'Null';
32+
return $display_string ?: self::$default_string_placeholder;
1833
}
1934

35+
/**
36+
* Nullified String only if Empty
37+
*
38+
* @param $string String to be nullified
39+
* @param string $display_string String to replace as placeholder
40+
* @return string
41+
*/
2042
public static function nullifiedIfEmpty($string, $display_string = '') {
2143
return $string ?: self::nullifiedToString($string, $display_string);
2244
}

0 commit comments

Comments
 (0)