Stringy\Stringy::__construct PHP Method

__construct() public method

Initializes a Stringy object and assigns both str and encoding properties the supplied values. $str is cast to a string prior to assignment, and if $encoding is not specified, it defaults to mb_internal_encoding(). Throws an InvalidArgumentException if the first argument is an array or object without a __toString method.
public __construct ( mixed $str = '', string $encoding = null )
$str mixed Value to modify, after being cast to string
$encoding string The character encoding
    public function __construct($str = '', $encoding = null)
    {
        if (is_array($str)) {
            throw new InvalidArgumentException('Passed value cannot be an array');
        } elseif (is_object($str) && !method_exists($str, '__toString')) {
            throw new InvalidArgumentException('Passed object must have a __toString method');
        }
        $this->str = (string) $str;
        $this->encoding = $encoding ?: \mb_internal_encoding();
    }