File "Shortcode.php"

Full Path: /home/warrior1/public_html/wp-content/plugins/file-manager/vendor/bitapps/wp-kit/src/Shortcode/Shortcode.php
File size: 1.12 KB
MIME-type: text/x-php
Charset: utf-8

<?php

namespace BitApps\WPKit\Shortcode;

use RuntimeException;

/**
 * A forwarder class for actions and filters.
 *
 * @method static void doShortcode( $content, $ignoreHtml = false )
 * @method static void addShortcode($tag, callable $callback)
 * @method static void removeShortcode($tag)
 * @method static bool shortcodeExists($tag)
 * @method static bool hasShortcode($content, $tag)
 */
final class Shortcode
{
    private static $_wrapper;

    public function __construct()
    {
        if (!isset(self::$_wrapper)) {
            self::$_wrapper = new ShortcodeWrapper();
        }
    }

    public function __call($method, $parameters)
    {
        if (method_exists($this->getInstance(), $method)) {
            return \call_user_func_array([$this->getInstance(), $method], $parameters);
        }

        throw new RuntimeException('Undefined method [' . $method . '] called on ' . __CLASS__ . ' class.');
    }

    public static function __callStatic($method, $parameters)
    {
        return (new static())->{$method}(...$parameters);
    }

    public function getInstance()
    {
        return self::$_wrapper;
    }
}