identifierType = Configuration::get(ConfigurationAdapter::CONF_OFFER_IDENTIFIER); } /** * @return bool|false|string */ public function getIdentifierType() { return $this->identifierType; } /** * @return string * @throws LogicException */ public function getFilterKey() { switch ($this->identifierType) { case self::IDENTIFIER_EAN: $key = 'p.ean13'; break; case self::IDENTIFIER_SKU: $key = 'p.reference'; break; default: throw new LogicException(sprintf('Unknown identifier type: "%s"', $this->identifierType)); } return $key; } /** * @param array $product * @return mixed|string * @throws LogicException */ public function extract(array $product) { switch ($this->identifierType) { case self::IDENTIFIER_EAN: $identifier = isset($product['ean13']) ? $product['ean13'] : ''; break; case self::IDENTIFIER_SKU: $identifier = isset($product['reference']) ? $product['reference'] : ''; break; default: throw new LogicException(sprintf('Unknown identifier type: "%s"', $this->identifierType)); } return $identifier; } }