示例#1
0
 /**
  * @param $segmentText
  * @throws JigException
  */
 protected function processInject($segmentText)
 {
     $namePattern = '#name=[\'"](' . self::FILENAME_PATTERN . ')[\'"]#u';
     $valuePattern = '#type=[\'"](.*)[\'"]#u';
     $nameMatchCount = preg_match($namePattern, $segmentText, $nameMatches);
     $valueMatchCount = preg_match($valuePattern, $segmentText, $valueMatches);
     if ($nameMatchCount === 0) {
         throw new JigException("Failed to get name for injection");
     }
     if ($valueMatchCount === 0) {
         throw new JigException("Failed to get value for injection");
     }
     $name = $nameMatches[1];
     $type = $valueMatches[1];
     if (strlen($type) === 0) {
         throw new JigException("Value must not be zero length");
     }
     $this->parsedTemplate->addInjection($name, $type);
 }