Example #1
0
 /**
  * Set the query part of the URL
  *
  * @param Query|string|array $query Query string value to set. Can
  *     be a string that will be parsed into a Query object, an array
  *     of key value pairs, or a Query object.
  *
  * @return Url
  * @throws \InvalidArgumentException
  */
 public function setQuery($query)
 {
     if ($query instanceof Query) {
         $this->query = $query;
     } elseif (is_string($query)) {
         $this->query = Query::fromString($query);
     } elseif (is_array($query)) {
         $this->query = new Query($query);
     } else {
         throw new \InvalidArgumentException('Query must be a ' . 'QueryInterface, array, or string');
     }
     return $this;
 }
Example #2
0
 /**
  * Set the query part of the URL
  *
  * @param Query|string|array $query Query string value to set. Can
  *     be a string that will be parsed into a Query object, an array
  *     of key value pairs, or a Query object.
  *
  * @throws \InvalidArgumentException
  */
 public function setQuery($query)
 {
     if ($query instanceof Query) {
         $this->query = $query;
     } elseif (is_string($query)) {
         $this->query = Query::fromString($query);
     } elseif (is_array($query)) {
         $this->query = new Query($query);
     } else {
         throw new \InvalidArgumentException('Query must be a Query, ' . 'array, or string. ' . gettype($query) . ' provided.');
     }
 }