private function add_query(puzzle_message_RequestInterface $request, $value) { if ($value instanceof puzzle_Query) { $original = $request->getQuery(); // Do not overwrite existing query string variables by overwriting // the object with the query string data passed in the URL $request->setQuery($value->overwriteWith($original->toArray())); } elseif (is_array($value)) { // Do not overwrite existing query string variables $query = $request->getQuery(); foreach ($value as $k => $v) { if (!isset($query[$k])) { $query[$k] = $v; } } } else { throw new InvalidArgumentException('query value must be an array ' . 'or puzzle_Query object'); } }