mageekguy\atoum\asserters\castToArray::setWith PHP Method

setWith() public method

public setWith ( $value )
    public function setWith($value)
    {
        parent::setWith($value, false);
        $fail = false;
        $this->adapter->set_error_handler(function () use(&$fail) {
            $fail = true;
        });
        switch (true) {
            case $this->value instanceof \Iterator:
                $value = iterator_to_array($this->value);
                break;
            case $this->getAnalyzer()->isString($value):
                $value = $this->adapter->str_split($value);
                $fail = $value === false;
                break;
            default:
                $value = (array) $value;
        }
        $this->adapter->restore_error_handler();
        if ($fail) {
            $this->fail($this->getLocale()->_('%s could not be converted to array', $this->getTypeOf($this->value)));
        }
        $this->value = $value;
        return $this->pass();
    }