1<?php
2
3namespace Emojione;
4
5class Emojione
6{
7    public static $ascii = false; // convert ascii smileys?
8    public static $unicodeAlt = true; // use the unicode char as the alt attribute (makes copy and pasting the resulting text better)
9    public static $imageType = 'png';
10    public static $cacheBustParam = '?v=2.2.7';
11    public static $sprites = false;
12    public static $imagePathPNG = 'https://cdn.jsdelivr.net/emojione/assets/png/';
13    public static $imagePathSVG = 'https://cdn.jsdelivr.net/emojione/assets/svg/';
14    public static $imagePathSVGSprites = './../../assets/sprites/emojione.sprites.svg';
15    public static $imageTitleTag = true;
16    public static $ignoredRegexp = '<object[^>]*>.*?<\/object>|<span[^>]*>.*?<\/span>|<(?:object|embed|svg|img|div|span|p|a)[^>]*>';
17    public static $unicodeRegexp = '([*#0-9](?>\\xEF\\xB8\\x8F)?\\xE2\\x83\\xA3|\\xC2[\\xA9\\xAE]|\\xE2..(\\xF0\\x9F\\x8F[\\xBB-\\xBF])?(?>\\xEF\\xB8\\x8F)?|\\xE3(?>\\x80[\\xB0\\xBD]|\\x8A[\\x97\\x99])(?>\\xEF\\xB8\\x8F)?|\\xF0\\x9F(?>[\\x80-\\x86].(?>\\xEF\\xB8\\x8F)?|\\x87.\\xF0\\x9F\\x87.|..((\\xE2\\x80\\x8D\\xF0\\x9F\\x97\\xA8)|(\\xF0\\x9F\\x8F[\\xBB-\\xBF])|(\\xE2\\x80\\x8D\\xF0\\x9F\\x91[\\xA6-\\xA9]){2,3}|(\\xE2\\x80\\x8D\\xE2\\x9D\\xA4\\xEF\\xB8\\x8F\\xE2\\x80\\x8D\\xF0\\x9F..(\\xE2\\x80\\x8D\\xF0\\x9F\\x91[\\xA6-\\xA9])?))?))';
18    public static $shortcodeRegexp = ':([-+\\w]+):';
19
20    protected static $client = null;
21
22    /**
23     * Magic caller
24     *
25     * @throws \BadMethodCallException If the method doesn't exists in client
26     */
27    public static function __callStatic($method, $args)
28    {
29        $client = static::getClient();
30
31        // DEPRECATED
32        static::updateConfig($client);
33
34        if ( ! method_exists($client, $method) )
35        {
36            throw new \BadMethodCallException('The method "' . $method . '" does not exist.');
37        }
38
39        return call_user_func_array(array($client, $method), $args);
40
41    }
42
43    /**
44     * Get the Client
45     *
46     * @return ClientInterface The Client
47     */
48    public static function getClient()
49    {
50        if ( static::$client === null )
51        {
52            static::setClient(new Client);
53        }
54
55        return static::$client;
56    }
57
58    /**
59     * Set the Client
60     *
61     * @param  ClientInterface $client The Client
62     * @return void
63     */
64    public static function setClient(ClientInterface $client)
65    {
66        // DEPRECATED
67        static::loadConfig($client);
68
69        static::$client = $client;
70    }
71
72    /**
73     * Load config from Client
74     *
75     * @deprecated
76     *
77     * @param  ClientInterface $client The Client
78     * @return self
79     */
80    protected static function loadConfig(ClientInterface $client)
81    {
82        static::$ascii               = $client->ascii;
83        static::$unicodeAlt          = $client->unicodeAlt;
84        static::$imageType           = $client->imageType;
85        static::$cacheBustParam      = $client->cacheBustParam;
86        static::$sprites             = $client->sprites;
87        static::$imagePathPNG        = $client->imagePathPNG;
88        static::$imagePathSVG        = $client->imagePathSVG;
89        static::$imageTitleTag       = $client->imageTitleTag;
90        static::$imagePathSVGSprites = $client->imagePathSVGSprites;
91        static::$ignoredRegexp       = $client->ignoredRegexp;
92        static::$unicodeRegexp       = $client->unicodeRegexp;
93        static::$shortcodeRegexp     = $client->shortcodeRegexp;
94    }
95
96    /**
97     * Update config in Client
98     *
99     * @deprecated
100     *
101     * @param  ClientInterface $client The Client
102     * @return self
103     */
104    protected static function updateConfig(ClientInterface $client)
105    {
106        $client->ascii               = static::$ascii;
107        $client->unicodeAlt          = static::$unicodeAlt;
108        $client->imageType           = static::$imageType;
109        $client->cacheBustParam      = static::$cacheBustParam;
110        $client->sprites             = static::$sprites;
111        $client->imagePathPNG        = static::$imagePathPNG;
112        $client->imagePathSVG        = static::$imagePathSVG;
113        $client->imageTitleTag       = static::$imageTitleTag;
114        $client->imagePathSVGSprites = static::$imagePathSVGSprites;
115        $client->ignoredRegexp       = static::$ignoredRegexp;
116        $client->unicodeRegexp       = static::$unicodeRegexp;
117        $client->shortcodeRegexp     = static::$shortcodeRegexp;
118    }
119}
120