attrName = $attrName; $this->queries = [$query]; $this->value = $value; } /** * Explode a string of space-separated values into an array * * @param string $attrValue Attribute's value * @return string[] */ protected function getValues(string $attrValue): array { return preg_match_all('(\\S++)', $attrValue, $m) ? $m[0] : []; } /** * {@inheritdoc} */ protected function normalizeElement(DOMElement $element): void { $currentValues = $this->getValues($element->getAttribute($this->attrName)); if (!in_array($this->value, $currentValues, true)) { $currentValues[] = $this->value; $element->setAttribute($this->attrName, implode(' ', $currentValues)); } } }