<commit_before><?php
namespace Gwa\Wordpress\WpBridge;

use stdClass;
use Gwa\Wordpress\WpBridge\Contracts\WpBridgeInterface;
use Mockery;

class MockeryWpBridge implements WpBridgeInterface
{
    /**
     * Mockery instance.
     *
     * @var \Mockery
     */
    private $mock;

    /**
     * All shortcodes.
     *
     * @var array
     */
    private $shortcodes = [];

    /**
     * All filters.
     *
     * @var array
     */
    private $filters = [];

    /**
     * All actions.
     *
     * @var array
     */
    private $actions = [];

    /**
     * All theme supports.
     *
     * @var array
     */
    private $themeSupport = [];

    /**
     * Add a shortcode.
     *
     * @param string $tag
     *
     * @param mixed $func
     */
    public function addShortcode($tag, $func)
    {
        $this->shortcodes[$tag] = $func;

        return $this;
    }

    /**
     * Check if shortcode exist.
     *
     * @param string $tag
     *
     * @return boolean
     */
    public function hasShortcode($tag)
    {
        return isset($this->shortcodes[$tag]);
    }

    /**
     * Get a shortcode callback.
     *
     * @param string $tag
     *
     * @return mixed
     */
    public function getShortcodeCallback($tag)
    {
        return isset($this->shortcodes[$tag]) ? $this->shortcodes[$tag] : null;
    }

    /**
     * Combines shortcode attributes with known attributes and fills in defaults when needed.
     *
     * @param array       $pairs
     * @param array       $atts
     * @param string|null $shortcode
     *
     * @return array
     */
    public function shortcodeAtts($pairs, $atts, $shortcode = null)
    {
        return array_merge($pairs, $atts);
    }

    /* -------- */

    /**
     * Wordpress mock on __() func.
     *
     * @param  string $text
     * @param  string $domain
     *
     * @return string
     */
    public function __($text, $domain)
    {
        return $text;
    }

    /* -------- */

    /**
     * Wordpress mock on add_filter func.
     *
     * @param string   $filterName
     * @param callback $filterCall
     * @param int      $prio
     * @param int      $numVars
     *
     * @return self
     */
    public function addFilter($filterName, $filterCall, $prio, $numVars)
    {
        $this->filters[] = $this->add($filterName, $filterCall, $prio, $numVars);

        return $this;
    }

    /**
     * Get all added filters.
     *
     * @return array
     */
    public function getAddedFilters()
    {
        return $this->filters;
    }

    /**
     * Wordpress mock on add_action func.
     *
     * @param string   $filterName
     * @param callback $filterCall
     * @param int      $prio
     * @param int      $numVars
     *
     * @return self
     */
    public function addAction($filterName, $filterCall, $prio, $numVars)
    {
        $this->actions[] = $this->add($filterName, $filterCall, $prio, $numVars);

        return $this;
    }

    /**
     * Get added actions
     *
     * @return array
     */
    public function getAddedActions()
    {
        return $this->actions;
    }

    /**
     * Wordpress mock on add_theme_support func.
     *
     * @param string $feature
     * @param array  $arguments
     *
     * @return self
     */
    public function addThemeSupport($feature, $arguments)
    {
        $data            = new stdClass();
        $data->feature   = $feature;
        $data->arguments = $arguments;

        $this->themeSupport[] = $data;

        return $this;
    }

    /**
     * Get added theme supports
     *
     * @return array
     */
    public function getAddedThemeSupport()
    {
        return $this->themeSupport;
    }

    public function mock()
    {
        if (!isset($this->mock)) {
            $this->mock = Mockery::mock('WpBridge');
        }

        return $this->mock;
    }

    public function __call($function, $args)
    {
        return call_user_func_array([$this->mock(), $function], $args);
    }

    /**
     * add
     *
     * @param string   $filterName
     * @param callback $filterCall
     * @param int      $prio
     * @param int      $numVars
     *
     * @return \stdClass
     */
    private function add($filterName, $filterCall, $prio, $numVars)
    {
        $data             = new stdClass();
        $data->filtername = $filterName;
        $data->callback   = $filterCall;
        $data->prio       = $prio;
        $data->numvars    = $numVars;

        return $data;
    }
}
<commit_msg>Added optional parameter to addFilter<commit_after><?php
namespace Gwa\Wordpress\WpBridge;

use stdClass;
use Gwa\Wordpress\WpBridge\Contracts\WpBridgeInterface;
use Mockery;

class MockeryWpBridge implements WpBridgeInterface
{
    /**
     * Mockery instance.
     *
     * @var \Mockery
     */
    private $mock;

    /**
     * All shortcodes.
     *
     * @var array
     */
    private $shortcodes = [];

    /**
     * All filters.
     *
     * @var array
     */
    private $filters = [];

    /**
     * All actions.
     *
     * @var array
     */
    private $actions = [];

    /**
     * All theme supports.
     *
     * @var array
     */
    private $themeSupport = [];

    /**
     * Add a shortcode.
     *
     * @param string $tag
     *
     * @param mixed $func
     */
    public function addShortcode($tag, $func)
    {
        $this->shortcodes[$tag] = $func;

        return $this;
    }

    /**
     * Check if shortcode exist.
     *
     * @param string $tag
     *
     * @return boolean
     */
    public function hasShortcode($tag)
    {
        return isset($this->shortcodes[$tag]);
    }

    /**
     * Get a shortcode callback.
     *
     * @param string $tag
     *
     * @return mixed
     */
    public function getShortcodeCallback($tag)
    {
        return isset($this->shortcodes[$tag]) ? $this->shortcodes[$tag] : null;
    }

    /**
     * Combines shortcode attributes with known attributes and fills in defaults when needed.
     *
     * @param array       $pairs
     * @param array       $atts
     * @param string|null $shortcode
     *
     * @return array
     */
    public function shortcodeAtts($pairs, $atts, $shortcode = null)
    {
        return array_merge($pairs, $atts);
    }

    /* -------- */

    /**
     * Wordpress mock on __() func.
     *
     * @param  string $text
     * @param  string $domain
     *
     * @return string
     */
    public function __($text, $domain)
    {
        return $text;
    }

    /* -------- */

    /**
     * Wordpress mock on add_filter func.
     *
     * @param string   $filterName
     * @param callback $filterCall
     * @param int      $prio
     * @param int      $numVars
     *
     * @return self
     */
    public function addFilter($filterName, $filterCall, $prio = 10, $numVars = 1)
    {
        $this->filters[] = $this->add($filterName, $filterCall, $prio, $numVars);

        return $this;
    }

    /**
     * Get all added filters.
     *
     * @return array
     */
    public function getAddedFilters()
    {
        return $this->filters;
    }

    /**
     * Wordpress mock on add_action func.
     *
     * @param string   $filterName
     * @param callback $filterCall
     * @param int      $prio
     * @param int      $numVars
     *
     * @return self
     */
    public function addAction($filterName, $filterCall, $prio, $numVars)
    {
        $this->actions[] = $this->add($filterName, $filterCall, $prio, $numVars);

        return $this;
    }

    /**
     * Get added actions
     *
     * @return array
     */
    public function getAddedActions()
    {
        return $this->actions;
    }

    /**
     * Wordpress mock on add_theme_support func.
     *
     * @param string $feature
     * @param array  $arguments
     *
     * @return self
     */
    public function addThemeSupport($feature, $arguments)
    {
        $data            = new stdClass();
        $data->feature   = $feature;
        $data->arguments = $arguments;

        $this->themeSupport[] = $data;

        return $this;
    }

    /**
     * Get added theme supports
     *
     * @return array
     */
    public function getAddedThemeSupport()
    {
        return $this->themeSupport;
    }

    public function mock()
    {
        if (!isset($this->mock)) {
            $this->mock = Mockery::mock('WpBridge');
        }

        return $this->mock;
    }

    public function __call($function, $args)
    {
        return call_user_func_array([$this->mock(), $function], $args);
    }

    /**
     * add
     *
     * @param string   $filterName
     * @param callback $filterCall
     * @param int      $prio
     * @param int      $numVars
     *
     * @return \stdClass
     */
    private function add($filterName, $filterCall, $prio, $numVars)
    {
        $data             = new stdClass();
        $data->filtername = $filterName;
        $data->callback   = $filterCall;
        $data->prio       = $prio;
        $data->numvars    = $numVars;

        return $data;
    }
}

{'fraction_non_alphanumeric': 0.13383475279283266, 'fraction_numerical': 0.0003318217011392545, 'mean_word_length': 1.646180860403863, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2616399', 'n_tokens_mistral': 2835, 'n_tokens_neox': 2787, 'n_words': 638}