private static function endsWithWhitespace($str) { if ('' === $str) { return false; } return '' === trim(substr($str, -1)); }