normalize($requested); if ($requested === '') { return false; } $values = [$product->getBarcode()?->getValue()]; foreach ($product->getAttributes() as $attribute) { if ($attribute instanceof AttributeDTO && in_array(strtolower(trim($attribute->getName())), self::FIELDS, true)) { $values[] = $attribute->getValue(); } } foreach ($values as $value) { if ($this->normalize((string) $value) === $requested) { return true; } } return false; } private function normalize(string $value): string { return strtolower((string) preg_replace('/[^a-z0-9]+/i', '', trim($value))); } }