* @copyright 2021 DIGITAL RETAIL TECHNOLOGIES SL * @license https://opensource.org/licenses/MIT The MIT License * * Don't forget to prefix your containers with your own identifier * to avoid any conflicts with others containers. */ class RetailcrmConsultantRcctExtractor extends RetailcrmAbstractDataBuilder { /** @var string */ const EXTRACT_REGEX = '/.*rcct(\s+)?\=(\s+)?[\'\"](?P[\w\d]+)[\'\"]/m'; /** @var string */ private $consultantScript; /** * @param string $consultantScript * * @return $this */ public function setConsultantScript($consultantScript) { $this->consultantScript = $consultantScript; $this->data = ''; return $this; } /** * Reset inner state * * @return $this */ public function reset() { parent::reset(); $this->consultantScript = ''; return $this; } /** * Build data * * @return $this */ public function build() { preg_match_all( static::EXTRACT_REGEX, $this->consultantScript, $this->data, PREG_SET_ORDER, 0 ); $this->data = reset($this->data); return $this; } /** * Returns string because token should be returned as string. * * @return string */ public function getDataString() { if (!empty($this->data) && is_array($this->data) && isset($this->data['token'])) { return $this->data['token']; } return ''; } }