public function render($xmlTag, $message)
 {
     $values = XmlParser::getValueBetweenTags($xmlTag, $message);
     $buildNewMessage = $message;
     foreach ($values as $val) {
         $valueReplaced = '<' . $xmlTag . '>' . $val . '</' . $xmlTag . '>';
         $valueResult = $this->_replaceTagColors($val);
         $buildNewMessage = str_replace($valueReplaced, $valueResult, $buildNewMessage);
     }
     return $buildNewMessage;
 }
예제 #2
0
 private function _parseMessage($message)
 {
     $parsedTags = array_unique(XmlParser::parseTags($message));
     $formatMessage = $message;
     foreach ($parsedTags as $xmlTag) {
         if (!empty($this->_formatters[$xmlTag])) {
             $formatter = $this->_formatters[$xmlTag];
             $formatMessage = $formatter->render($xmlTag, $formatMessage);
         }
     }
     return $formatMessage;
 }
 /**
  * @test
  */
 public function shouldNotReturnWhenTagNotFound()
 {
     //given
     $stringToParse = '<tag>Is ok</tag> now, maybe <tag>multiple</tag>?';
     //when
     $expectedXml = array();
     $actualXml = \Psf\XmlParser::getValueBetweenTags('another_tag', $stringToParse);
     //then
     $this->assertEquals($expectedXml, $actualXml);
 }