cast $str to (string) for mb_detect_encoding

"mb_detect_encoding() expects parameter 1 to be string, object given". Adding (string) prevents errors in the event $str is not a string.

Alternatively, you could use strval($str).

Typehinting scalar types won't work either.

I understand, the user should know to pass the string, but because it expects a string, we might as well typecast it for preventative measures.  And ironically, because the above error is thrown, I cannot identify the source or stacktrace quickly :)

Fix for #32