View file MMO-Hide-2.3.4/upload/src/addons/MMO/Hide/Data/HideTags.php

File size: 1.27Kb
<?php

namespace MMO\Hide\Data;

/**
 * Class HideTags
 * @package MMO\Hide\BbCode
 */
class HideTags
{
    /**
     * @return array
     */
    public function getHideTags(): array
    {
        $tags = [
            'hide',
            'posts',
            'likes',
            'days',
            'trophies',
            'club',
            'groups',
            'thanks',
            'reacts',
            'reply',
            'replythanks',
            'replyandthanks',
            'users',
            'usersid',
            'usersexc',
            'usersidexc',
            'hideuserage'
        ];

        \XF::fire('mh_hide_add_tag_codes', [&$tags]);

        return $tags;
    }

    /**
     * @param $string
     * @param string $replacement
     * @return string|string[]
     */
    public function stripHideTags($string, string $replacement = '')
    {
        return \preg_replace('#\[(' . implode ('|', $this->getHideTags()) . ')(=[^\]]*)?\](.*)\[/\1\]#siU', $replacement, $string);
    }

    /**
     * @param $string
     * @return false|int
     */
    public function findHideTags($string)
    {
        return \preg_match('#\[(' . implode ('|', $this->getHideTags()) . ')(=[^\]]*)?\](.*)\[/\1\]#siU', $string);
    }
}