/** * @param string|array $json * * @throws InvalidArgumentException * @return DumpQuery */ public static function jsonDeserialize($json) { if (!is_array($json) && !is_string($json)) { throw new InvalidArgumentException('jsonDeserialize needs an array or string'); } if (is_string($json)) { $array = json_decode($json, true); } else { $array = $json; } $obj = new self(); foreach ($array['ns'] as $ns) { $obj->addNamespaceFilter($ns); } foreach ($array['title'] as $type => $titleFilters) { foreach ($titleFilters as $filter) { $obj->addTitleFilter($filter, $type); } } foreach ($array['text'] as $type => $textFilters) { foreach ($textFilters as $filter) { $obj->addTextFilter($filter, $type); } } return $obj; }