Exemplo n.º 1
0
 public static function parse(&$line)
 {
     $alertMessage = new AlertMessage();
     /* from php.net
      * If matches is provided, then it is filled with the results of 
      * search. $matches[0] will contain the text that matched the 
      * full pattern, $matches[1] will have the text that matched the 
      * first captured parenthesized subpattern, and so on. 
      */
     if (preg_match(self::MESSAGE_PATTERN, trim($line), $matches)) {
         $alertMessage->setMessage($matches[1]);
     }
     if (preg_match(self::REVISION_PATTERN, trim($line), $matches)) {
         $alertMessage->setRevision($matches[1]);
         echo "Rev Set: " . $matches[1] . "<br/>";
         echo "Line is: " . htmlentities(trim($line)) . "<br/>";
     }
     if (preg_match(self::SEVERITY_PATTERN, trim($line), $matches)) {
         $alertMessage->setSeverity($matches[1]);
     }
     if (preg_match(self::ID_PATTERN, trim($line), $matches)) {
         $alertMessage->setId($matches[1]);
     }
     if (preg_match(self::GENERAL_MESSAGE_PATTERN, trim($line), $matches)) {
         $alertMessage->setGeneralMessage($matches[1]);
     }
     if (preg_match(self::TECHNICAL_MESSAGE_PATTERN, trim($line), $matches)) {
         $alertMessage->setTechnicalMessage($matches[1]);
     }
     return $alertMessage;
 }