[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/s9e/text-formatter/src/Plugins/Keywords/ -> Parser.php (source)

   1  <?php
   2  
   3  /*
   4  * @package   s9e\TextFormatter
   5  * @copyright Copyright (c) 2010-2019 The s9e Authors
   6  * @license   http://www.opensource.org/licenses/mit-license.php The MIT License
   7  */
   8  namespace s9e\TextFormatter\Plugins\Keywords;
   9  use s9e\TextFormatter\Plugins\ParserBase;
  10  class Parser extends ParserBase
  11  {
  12  	public function parse($text, array $matches)
  13      {
  14          $regexps  = $this->config['regexps'];
  15          $tagName  = $this->config['tagName'];
  16          $attrName = $this->config['attrName'];
  17          $onlyFirst = !empty($this->config['onlyFirst']);
  18          $keywords  = [];
  19          foreach ($regexps as $regexp)
  20          {
  21              \preg_match_all($regexp, $text, $matches, \PREG_OFFSET_CAPTURE);
  22              foreach ($matches[0] as $_11955a1f)
  23              {
  24                  list($value, $pos) = $_11955a1f;
  25                  if ($onlyFirst)
  26                  {
  27                      if (isset($keywords[$value]))
  28                          continue;
  29                      $keywords[$value] = 1;
  30                  }
  31                  $this->parser->addSelfClosingTag($tagName, $pos, \strlen($value))
  32                               ->setAttribute($attrName, $value);
  33              }
  34          }
  35      }
  36  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1