public function slice($offset, $length = null, $preserveKeys = false, $asArray = false)
    {
        if (!is_int($offset)) {
            throw new InvalidArgumentException('integer', 0);
        }
        if (!is_null($length) && !is_int($length)) {
            throw new InvalidArgumentException('integer', 1);
        }
        $preserveKeys = !!$preserveKeys;

        $array = $this->getArrayCopy();
        $newArray = array_slice($array, $offset, $length, $preserveKeys);
        return (!!$asArray) ? $newArray : new self($newArray);
    }