|
@@ 167-175 (lines=9) @@
|
| 164 |
|
* @return string Same string given, but ensured that is not empty. |
| 165 |
|
* @throws InvalidArgumentException if string is null or empty. |
| 166 |
|
*/ |
| 167 |
|
public static function ensureIsNotEmpty($string) |
| 168 |
|
{ |
| 169 |
|
if (static::ensureIsString($string) === '') { |
| 170 |
|
$msg = msg('Provided string must not be empty.'); |
| 171 |
|
throw new InvalidArgumentException($msg); |
| 172 |
|
} |
| 173 |
|
|
| 174 |
|
return $string; |
| 175 |
|
} |
| 176 |
|
|
| 177 |
|
/** |
| 178 |
|
* Ensures that given string is not empty or whitespaces. |
|
@@ 186-194 (lines=9) @@
|
| 183 |
|
* @throws InvalidArgumentException if object is not an `string`. |
| 184 |
|
* @see \trim() |
| 185 |
|
*/ |
| 186 |
|
public static function ensureIsNotWhiteSpaces($string) |
| 187 |
|
{ |
| 188 |
|
if (trim(static::ensureIsNotEmpty($string)) === '') { |
| 189 |
|
$msg = msg('Provided string must not be white spaces.'); |
| 190 |
|
throw new InvalidArgumentException($msg); |
| 191 |
|
} |
| 192 |
|
|
| 193 |
|
return $string; |
| 194 |
|
} |
| 195 |
|
|
| 196 |
|
/** |
| 197 |
|
* Ensures that an string follows the PHP variables naming convention. |