public function testNameExtractPatternCanBeSet()
 {
     $this->subjectUnderTest->setNameExtractPattern('/./');
     $this->assertSame('/./', $this->subjectUnderTest->getNameExtractPattern());
     $this->subjectUnderTest->setNameExtractPattern('/a/');
     $this->assertSame('/a/', $this->subjectUnderTest->getNameExtractPattern());
 }
 /**
  * This method will try to extract title according to rules defined in config.
  *
  * @param $string
  *
  * @return false|string Will return title or false if extraction didn't produced any result.
  * @throws RegexException Supplied extraction regex is invalid.
  */
 public function extractTitle($string)
 {
     $matchResult = @preg_match($this->configuration->getNameExtractPattern(), $string, $matches);
     if ($matchResult === false) {
         throw new RegexException('Pattern was configured for ' . $this->getName() . ' aggregator to extract name', $this->configuration->getNameExtractPattern());
     } elseif ($matchResult === 0 || !isset($matches[1])) {
         //No matches or empty match
         return false;
     } elseif (isset($matches[2])) {
         $this->logger->warning('Pattern ' . $this->configuration->getNameExtractPattern() . ' configured in ' . $this->getName() . ' aggregator to extract title resulted in ' . (count($matches) - 1) . ' matches instead of one for input string "' . $string . '". Only first one will be used.');
     }
     return $matches[1];
 }