@@ 148-156 (lines=9) @@ | ||
145 | * @return string Same string given, but ensured that is not empty. |
|
146 | * @throws InvalidArgumentException if string is null or empty. |
|
147 | */ |
|
148 | public static function ensureIsNotEmpty($string) |
|
149 | { |
|
150 | if (static::ensureIsString($string) === '') { |
|
151 | $msg = nml_msg('Provided string must not be empty.'); |
|
152 | throw new InvalidArgumentException($msg); |
|
153 | } |
|
154 | ||
155 | return $string; |
|
156 | } |
|
157 | ||
158 | /** |
|
159 | * Ensures that given string is not empty or whitespaces. |
|
@@ 167-175 (lines=9) @@ | ||
164 | * @throws InvalidArgumentException if object is not an `string`. |
|
165 | * @see trim |
|
166 | */ |
|
167 | public static function ensureIsNotWhiteSpaces($string) |
|
168 | { |
|
169 | if (trim(static::ensureIsNotEmpty($string)) === '') { |
|
170 | $msg = nml_msg('Provided string must not be white spaces.'); |
|
171 | throw new InvalidArgumentException($msg); |
|
172 | } |
|
173 | ||
174 | return $string; |
|
175 | } |
|
176 | ||
177 | /** |
|
178 | * Ensures that an string follows the PHP variables naming convention. |