1 | <?php |
||
26 | class StringHelper |
||
27 | { |
||
28 | /** |
||
29 | * The bool variants available in .env |
||
30 | * |
||
31 | * @var array $bool_variants |
||
32 | */ |
||
33 | private static $bool_variants = array( |
||
34 | 'true', 'false', 'yes', 'no' |
||
35 | ); |
||
36 | |||
37 | /** |
||
38 | * Returns if value is a bool |
||
39 | * |
||
40 | * @param string $value The value to test |
||
41 | * |
||
42 | * @return bool Is a value a bool |
||
43 | */ |
||
44 | 45 | public function isBool($value) |
|
48 | |||
49 | /** |
||
50 | * Returns if the bool is in a string |
||
51 | * |
||
52 | * @param string $value The value to test |
||
53 | * @param bool $quoted_string Is the context a quoted string |
||
54 | * @param int $word_count The amount of words in the sentence |
||
55 | * |
||
56 | * @return bool Is a value a bool in a string |
||
57 | */ |
||
58 | 15 | public function isBoolInString($value, $quoted_string, $word_count) |
|
62 | |||
63 | /** |
||
64 | * Returns if value is null |
||
65 | * |
||
66 | * @param string $value The value to test |
||
67 | * |
||
68 | * @return bool Is a value null |
||
69 | */ |
||
70 | 42 | public function isNull($value) |
|
74 | |||
75 | /** |
||
76 | * Returns if value is number |
||
77 | * |
||
78 | * @param string $value The value to test |
||
79 | * |
||
80 | * @return bool Is a value a number |
||
81 | */ |
||
82 | 42 | public function isNumber($value) |
|
86 | |||
87 | /** |
||
88 | * Returns if value is a string |
||
89 | * |
||
90 | * @param string $value The value to test |
||
91 | * |
||
92 | * @return bool Is a value a string |
||
93 | */ |
||
94 | 48 | public function isString($value) |
|
98 | |||
99 | /** |
||
100 | * Returns if variable value is a clone, e.g. BOOL = $(BOOL_1) |
||
101 | * |
||
102 | * @param string $value The value to test |
||
103 | * @param array $matches The matches of the variables |
||
104 | * @param bool $quoted_string If the value is in a quoted string |
||
105 | * |
||
106 | * @return bool Is a value null |
||
107 | */ |
||
108 | 21 | public function isVariableClone($value, $matches, $quoted_string) |
|
112 | |||
113 | /** |
||
114 | * Returns if value starts with a value |
||
115 | * |
||
116 | * @param string $string The value to search for |
||
117 | * @param string $line The line to test |
||
118 | * |
||
119 | * @return bool Returns if the line starts with value |
||
120 | */ |
||
121 | 60 | public function startsWith($string, $line) |
|
125 | |||
126 | /** |
||
127 | * Returns if value starts with a number |
||
128 | * |
||
129 | * @param string $line The line to test |
||
130 | * |
||
131 | * @return bool Returns if the line starts with a number |
||
132 | */ |
||
133 | 51 | public function startsWithNumber($line) |
|
137 | |||
138 | /** |
||
139 | * Strips comments from a value |
||
140 | * |
||
141 | * @param string $value The value to strip comments from |
||
142 | * |
||
143 | * @return string value |
||
144 | */ |
||
145 | 45 | public function stripComments($value) |
|
150 | } |
||
151 |