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