public function exchangeArray($collection)
    {
        if (!is_array($collection) && !($collection instanceof Traversable)) {
            throw new Exception\InvalidArgumentException(
                sprintf(
                    'Expected argument "array" or "Traversable"; "%s" given',
                    gettype($collection) . (is_object($collection) ? '(' . get_class($collection) . ')' : '')
                )
            );
        }

        if ($collection instanceof Traversable) {
            $collection = ArrayUtils::iteratorToArray($collection);
        }

        foreach ($collection as $key => $value) {
            $this->set($key, $value);
        }
    }
public function exchangeArray($collection)
    {
        if (!is_array($collection) && !($collection instanceof Traversable)) {
            throw new Exception\InvalidArgumentException(
                sprintf(
                    'Expected argument "array" or "Traversable"; "%s" given',
                    gettype($collection) . (is_object($collection) ? '(' . get_class($collection) . ')' : '')
                )
            );
        }

        if ($collection instanceof Traversable) {
            $collection = ArrayUtils::iteratorToArray($collection);
        }

        foreach ($collection as $key => $value) {
            $this->set($key, $value);
        }
    }
public function exchangeArray ( $ collection ) { if ( ! is_array ( $ collection ) && ! ( $ collection instanceof Traversable ) ) { throw new Exception \ InvalidArgumentException ( sprintf ( 'Expected argument "array" or "Traversable"; "%s" given' , gettype ( $ collection ) . ( is_object ( $ collection ) ? '(' . get_class ( $ collection ) . ')' : '' ) ) ) ; } if ( $ collection instanceof Traversable ) { $ collection = ArrayUtils :: iteratorToArray ( $ collection ) ; } foreach ( $ collection as $ key => $ value ) { $ this -> set ( $ key , $ value ) ; } }
Sets a whole new array replacement.

@param array|Traversable $collection

@return void
@throws \Xloit\Collection\Exception\InvalidArgumentException
@throws \Zend\Stdlib\Exception\InvalidArgumentException
Sets a whole new array replacement .