├── .gitignore ├── CHANGELOG.md ├── src ├── Exceptions │ ├── IsNull.php │ ├── UnknownEmoji.php │ ├── UnknownMethod.php │ └── UnknownUnicode.php ├── Facades │ └── Emoji.php ├── EmojiServiceProvider.php ├── Emoji.php └── Emojis │ └── emoji.php ├── .travis.yml ├── composer.json ├── phpunit.xml.dist ├── LICENSE.md ├── CONTRIBUTING.md ├── README.md └── tests └── EmojiTest.php /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | vendor 3 | .DS_Store 4 | composer.lock -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All Notable changes to `laravel-emoji` will be documented in this file 4 | 5 | ## 2016-02-08 6 | - Initial release -------------------------------------------------------------------------------- /src/Exceptions/IsNull.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace Unicodeveloper\Emoji\Exceptions; 13 | 14 | use Exception; 15 | 16 | class IsNull extends Exception 17 | { 18 | public static function create($message) : IsNull 19 | { 20 | return new static("{$message}"); 21 | } 22 | } -------------------------------------------------------------------------------- /src/Exceptions/UnknownEmoji.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace Unicodeveloper\Emoji\Exceptions; 13 | 14 | use Exception; 15 | 16 | class UnknownEmoji extends Exception 17 | { 18 | public static function create($emoji) : UnknownEmoji 19 | { 20 | return new static("Emoji {$emoji} Not Found, Man. Check your spelling and try again"); 21 | } 22 | } -------------------------------------------------------------------------------- /src/Exceptions/UnknownMethod.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace Unicodeveloper\Emoji\Exceptions; 13 | 14 | use Exception; 15 | 16 | class UnknownMethod extends Exception 17 | { 18 | public static function create($method) : UnknownMethod 19 | { 20 | return new static("This method {$method} does not exist in this package. Please check the documentation"); 21 | } 22 | } -------------------------------------------------------------------------------- /src/Exceptions/UnknownUnicode.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace Unicodeveloper\Emoji\Exceptions; 13 | 14 | use Exception; 15 | 16 | class UnknownUnicode extends Exception 17 | { 18 | public static function create($unicode) : UnknownUnicode 19 | { 20 | return new static("Unicode {$unicode} Not Found, Man. Please provide a valid UTF-8 Unicode value"); 21 | } 22 | } -------------------------------------------------------------------------------- /src/Facades/Emoji.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace Unicodeveloper\Emoji\Facades; 13 | 14 | use Illuminate\Support\Facades\Facade; 15 | 16 | class Emoji extends Facade { 17 | 18 | /** 19 | * Get the registered name of the component. 20 | * 21 | * @return string 22 | */ 23 | protected static function getFacadeAccessor() : string 24 | { 25 | return 'laravel-emoji'; 26 | } 27 | } -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | php: 4 | - 7.0 5 | - hhvm 6 | 7 | matrix: 8 | allow_failures: 9 | - php: hhvm 10 | 11 | install: travis_retry composer install --no-interaction --prefer-source 12 | 13 | script: 14 | - mkdir -p build/logs 15 | - php vendor/bin/phpunit -c phpunit.xml.dist 16 | - phpunit --coverage-text --coverage-clover=coverage.clover 17 | - phpunit --coverage-clover build/logs/clover.xml 18 | 19 | after_script: 20 | - wget https://scrutinizer-ci.com/ocular.phar 21 | - php ocular.phar code-coverage:upload --format=php-clover coverage.clover 22 | - travis_retry php vendor/bin/coveralls -v 23 | 24 | notifications: 25 | slack: red-creek:5lI8ybvl6YTcCNPosh4TE13h -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "unicodeveloper/laravel-emoji", 3 | "description": "A Laravel 5 Package for Using & Working With Emojis", 4 | "keywords": ["php","github","laravel","Open Source","emoji","unicode","laravel 5"], 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "unicodeveloper", 9 | "email": "prosperotemuyiwa@gmail.com", 10 | "role": "Developer" 11 | } 12 | ], 13 | "minimum-stability": "stable", 14 | "require": { 15 | "php": "^7.0", 16 | "illuminate/support": "5.*" 17 | }, 18 | "require-dev": { 19 | "phpunit/phpunit" : "4.*", 20 | "scrutinizer/ocular": "~1.1", 21 | "satooshi/php-coveralls": "^0.7.0" 22 | }, 23 | "autoload": { 24 | "psr-4": { 25 | "Unicodeveloper\\Emoji\\": "src/" 26 | } 27 | }, 28 | "autoload-dev": { 29 | "psr-4": { 30 | "Unicodeveloper\\Emoji\\Test\\": "tests" 31 | } 32 | }, 33 | "scripts": { 34 | "test": "vendor/bin/phpunit" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/EmojiServiceProvider.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace Unicodeveloper\Emoji; 13 | 14 | use Illuminate\Support\ServiceProvider; 15 | 16 | class EmojiServiceProvider extends ServiceProvider { 17 | 18 | /* 19 | * Indicates if loading of the provider is deferred. 20 | * 21 | * @var bool 22 | */ 23 | protected $defer = false; 24 | 25 | 26 | /** 27 | * Register the application services. 28 | * 29 | * @return void 30 | */ 31 | public function register() 32 | { 33 | $this->app->bind('laravel-emoji', function() { 34 | 35 | return new Emoji; 36 | 37 | }); 38 | } 39 | 40 | /** 41 | * Get the services provided by the provider 42 | * @return array 43 | */ 44 | public function provides() : array 45 | { 46 | return ['laravel-emoji']; 47 | } 48 | } -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | tests 15 | 16 | 17 | 18 | 19 | src/ 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Prosper Otemuyiwa 4 | 5 | > Permission is hereby granted, free of charge, to any person obtaining a copy 6 | > of this software and associated documentation files (the "Software"), to deal 7 | > in the Software without restriction, including without limitation the rights 8 | > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | > copies of the Software, and to permit persons to whom the Software is 10 | > furnished to do so, subject to the following conditions: 11 | > 12 | > The above copyright notice and this permission notice shall be included in 13 | > all copies or substantial portions of the Software. 14 | > 15 | > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | > THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are **welcome** and will be fully **credited**. 4 | 5 | We accept contributions via Pull Requests on [Github](https://github.com/unicodeveloper/laravel-emoji). 6 | 7 | 8 | ## Pull Requests 9 | 10 | - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer). 11 | 12 | - **Add tests!** - Your patch won't be accepted if it doesn't have tests. 13 | 14 | - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. 15 | 16 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. 17 | 18 | - **Create feature branches** - Don't ask us to pull from your master branch. 19 | 20 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 21 | 22 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. 23 | 24 | 25 | ## Running Tests 26 | 27 | ``` bash 28 | $ composer test 29 | ``` 30 | 31 | 32 | **Happy coding**! 33 | -------------------------------------------------------------------------------- /src/Emoji.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace Unicodeveloper\Emoji; 13 | 14 | use Unicodeveloper\Emoji\Exceptions\{ UnknownMethod, UnknownEmoji, UnknownUnicode, IsNull }; 15 | 16 | class Emoji { 17 | 18 | /** 19 | * Get the Emojis from emoji.php 20 | * @return array 21 | */ 22 | private function getEmojis() : array 23 | { 24 | return require("Emojis/emoji.php"); 25 | } 26 | 27 | /** 28 | * Get the emoji by passing the commonly used emoji name 29 | * @param string $emojiName 30 | * @return unicode 31 | * @throws \Unicodeveloper\Emoji\Exceptions\IsNull 32 | * @throws \Unicodeveloper\Emoji\Exceptions\UnknownUnicode 33 | */ 34 | public function findByAlias($emojiName = null) : string 35 | { 36 | if (is_null($emojiName)) { 37 | throw IsNull::create("Please provide the name of the emoji you are looking for"); 38 | } 39 | 40 | $emoji = strtolower($emojiName); 41 | 42 | if (! array_key_exists($emoji, $this->getEmojis())) { 43 | throw UnknownEmoji::create($emoji); 44 | } 45 | 46 | return $this->getEmojis()[$emoji]; 47 | } 48 | 49 | /** 50 | * Get the emoji by passing the commonly used emoji name 51 | * Alias for findByAlias 52 | * @param string $emojiName 53 | * @return unicode 54 | */ 55 | public function findByName($emojiName = null) : string 56 | { 57 | return $this->findByAlias($emojiName); 58 | } 59 | 60 | /** 61 | * Get the emoji name by passing the unicode value 62 | * @param string $unicode 63 | * @return string 64 | * @throws \Unicodeveloper\Emoji\Exceptions\IsNull 65 | * @throws \Unicodeveloper\Emoji\Exceptions\UnknownUnicode 66 | */ 67 | public function findByUnicode($unicode = null) : string 68 | { 69 | if (is_null($unicode)) { 70 | throw IsNull::create("Please provide a valid UTF-8 Unicode value"); 71 | } 72 | 73 | $emojis = array_flip($this->getEmojis()); 74 | 75 | if (! array_key_exists($unicode, $emojis)) { 76 | throw UnknownUnicode::create($unicode); 77 | } 78 | 79 | return $emojis[$unicode]; 80 | } 81 | 82 | /** 83 | * Ensure that a proper exception is thrown for methods that do not exist 84 | * @param string $method 85 | * @param array $parameters 86 | * @throws \Unicodeveloper\Emoji\Exceptions\UnknownMethod 87 | */ 88 | public function __call($method, $parameters) 89 | { 90 | if (! method_exists(new static, $method)) { 91 | throw UnknownMethod::create($method); 92 | } 93 | } 94 | 95 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # laravel-emoji 2 | 3 | ![emoji](https://cloud.githubusercontent.com/assets/2946769/12880382/25da8dd6-ce40-11e5-8bfd-ee2b547bb11e.png) 4 | [![Latest Stable Version](https://poser.pugx.org/unicodeveloper/laravel-emoji/v/stable.svg)](https://packagist.org/packages/unicodeveloper/laravel-emoji) 5 | [![License](https://poser.pugx.org/unicodeveloper/laravel-emoji/license.svg)](LICENSE.md) 6 | [![Build Status](https://img.shields.io/travis/unicodeveloper/laravel-emoji.svg)](https://travis-ci.org/unicodeveloper/laravel-emoji) 7 | [![Quality Score](https://img.shields.io/scrutinizer/g/unicodeveloper/laravel-emoji.svg?style=flat-square)](https://scrutinizer-ci.com/g/unicodeveloper/laravel-emoji) 8 | [![Total Downloads](https://img.shields.io/packagist/dt/unicodeveloper/laravel-emoji.svg?style=flat-square)](https://packagist.org/packages/unicodeveloper/laravel-emoji) 9 | 10 | > A Laravel 5 Package for Using & Working With Emojis in your Laravel Apps 11 | 12 | ## Installation 13 | 14 | [PHP](https://php.net) 7 and [Composer](https://getcomposer.org) are required. 15 | 16 | To get the latest version of Laravel Emoji, simply add the following line to the require block of your `composer.json` file. 17 | 18 | ``` 19 | "unicodeveloper/laravel-emoji": "1.0.*" 20 | ``` 21 | 22 | You'll then need to run `composer install` or `composer update` to download it and have the autoloader updated. 23 | 24 | Once Laravel Emoji is installed, you need to register the service provider. Open up `config/app.php` and add the following to the `providers` key. 25 | 26 | * `Unicodeveloper\Emoji\EmojiServiceProvider::class` 27 | 28 | Also, register the Facade like so: 29 | 30 | ```php 31 | 'aliases' => [ 32 | ... 33 | 'Emoji' => Unicodeveloper\Emoji\Facades\Emoji::class, 34 | ... 35 | ] 36 | ``` 37 | 38 | ## Usage 39 | 40 | Translate Emoji names to Unicode and Vice-versa. 41 | 42 | ```php 43 | >> Emoji::findByAlias("kissing_heart") 44 | => "😘" 45 | 46 | >> Emoji::findByName("sunglasses") 47 | => "😎" 48 | 49 | >> Emoji::findByUnicode("\u{1F603}") 50 | => "smiley" 51 | 52 | ``` 53 | This package contains some of the characters listed on http://unicode.org/emoji/charts/full-emoji-list.html 54 | 55 | ## Contributing 56 | 57 | Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities. 58 | 59 | I am accepting PR's that add characters to emoji.php. 60 | Please use [this list](http://unicode.org/emoji/charts/full-emoji-list.html) to look up the unicode value and 61 | the name of the character. 62 | 63 | ## How can I thank you? 64 | 65 | Why not star the github repo? I'd love the attention! Why not share the link for this repository on Twitter or HackerNews? Spread the word! 66 | 67 | Don't forget to [follow me on twitter](https://twitter.com/unicodeveloper)! 68 | 69 | Thanks! 70 | Prosper Otemuyiwa. 71 | 72 | ## Inspiration 73 | 74 | * [Emoji](https://github.com/spatie/emoji) 75 | 76 | ## License 77 | 78 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 79 | -------------------------------------------------------------------------------- /src/Emojis/emoji.php: -------------------------------------------------------------------------------- 1 | "\u{1F382}", 17 | "running" => "\u{1F3C3}", 18 | "house" => "\u{1F3E0}", 19 | "office" => "\u{1F3E2}", 20 | "shit" => "\u{1F4A9}", 21 | "computer" => "\u{1F4BB}", 22 | "moneybag" => "\u{1F4B0}", 23 | "camera" => "\u{1F4F7}", 24 | "thumbsup" => "\u{1F44D}", 25 | "thumbsdown" => "\u{1F44E}", 26 | "family" => "\u{1F46A}", 27 | "kiss" => "\u{1F48B}", 28 | "gun" => "\u{1F52B}", 29 | "grinning" => "\u{1F600}", 30 | "grin" => "\u{1F601}", 31 | "joy" => "\u{1F602}", 32 | "smiley" => "\u{1F603}", 33 | "smile" => "\u{1F604}", 34 | "sweat_smile" => "\u{1F605}", 35 | "laughing" => "\u{1F606}", 36 | "wink" => "\u{1F609}", 37 | "blush" => "\u{1F60A}", 38 | "yum" => "\u{1F60B}", 39 | "relieved" => "\u{1F60C}", 40 | "sunglasses" => "\u{1F60E}", 41 | "heart_eyes" => "\u{1F60D}", 42 | "kissing_heart" => "\u{1F618}", 43 | "kissing" => "\u{1F617}", 44 | "kissing_smiling_eyes" => "\u{1F619}", 45 | "kissing_closed_eyes" => "\u{1F61A}", 46 | "stuck_out_tongue" => "\u{1F61C}", 47 | "stuck_out_tongue_closed_eyes" => "\u{1F61D}", 48 | "disappointed" => "\u{1F61E}", 49 | "angry" => "\u{1F620}", 50 | "pout" => "\u{1F621}", 51 | "cry" => "\u{1F622}", 52 | "persevere" => "\u{1F623}", 53 | "triumph" => "\u{1F624}", 54 | "disappointed_relived" => "\u{1F625}", 55 | "fearful" => "\u{1F628}", 56 | "weary" => "\u{1F629}", 57 | "sleepy" => "\u{1F62A}", 58 | "tired" => "\u{1F62B}", 59 | "loudly_cry" => "\u{1F62D}", 60 | "cold_sweat" => "\u{1F630}", 61 | "scream" => "\u{1F631}", 62 | "astonished" => "\u{1F632}", 63 | "flushed" => "\u{1F633}", 64 | "dizzy_face" => "\u{1F635}", 65 | "mask" => "\u{1F637}", 66 | "grinning_cat" => "\u{1F638}", 67 | "joy_cat" => "\u{1F639}", 68 | "smiling_cat" => "\u{1F63A}", 69 | "no_good" => "\u{1F645}", 70 | "ok_woman" => "\u{1F646}", 71 | "bow" => "\u{1F647}", 72 | "see_no_evil" => "\u{1F648}", 73 | "hear_no_evil" => "\u{1F649}", 74 | "speak_no_evil" => "\u{1F64A}", 75 | "raising_hand" => "\u{1F64B}", 76 | "raised_hands" => "\u{1F64C}", 77 | "person_frowning" => "\u{1F64D}", 78 | "pray" => "\u{1F64F}", 79 | "worried" => "\u{1F61F}", 80 | "cry" => "\u{1F622}", 81 | "scream" => "\u{1F631}", 82 | "raised_hands" => "\u{1F64C}", 83 | "pray" => "\u{1F64F}", 84 | "relaxed" => "\u{263A}", 85 | "white_check_mark" => "\u{2705}", 86 | "question" => "\u{2753}" 87 | ]; 88 | -------------------------------------------------------------------------------- /tests/EmojiTest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace Unicodeveloper\Emoji\Test; 13 | 14 | use ReflectionClass; 15 | use PHPUnit_Framework_TestCase; 16 | use Unicodeveloper\Emoji\Emoji; 17 | 18 | class EmojiTest extends PHPUnit_Framework_TestCase 19 | { 20 | protected $emoji; 21 | 22 | public function setUp() 23 | { 24 | $this->emoji = new Emoji; 25 | } 26 | 27 | /** 28 | * Test the private getEmojis method 29 | * @return boolean 30 | */ 31 | public function testGetEmojis() 32 | { 33 | $result = $this->invokeMethod($this->emoji, 'getEmojis'); 34 | $this->assertArrayHasKey('joy', $result); 35 | } 36 | 37 | /** 38 | * Test that the method findByAlias returns the correct unicode value 39 | * @return boolean 40 | */ 41 | public function testFindByAliasReturnsAppropriateUnicodeValue() 42 | { 43 | $unicodeValue = $this->emoji->findByAlias('wink'); 44 | 45 | $realResult = $this->getEmojis(); 46 | 47 | $this->assertEquals($unicodeValue, $realResult['wink']); 48 | } 49 | 50 | /** 51 | * Test that the method findByName returns the correct unicode value 52 | * @return boolean 53 | */ 54 | public function testFindByNamesReturnsAppropriateUnicodeValue() 55 | { 56 | $unicodeValue = $this->emoji->findByName('wink'); 57 | 58 | $realResult = $this->getEmojis(); 59 | 60 | $this->assertEquals($unicodeValue, $realResult['wink']); 61 | } 62 | 63 | /** 64 | * Test that the method findByUnicode returns the correct emoji name 65 | * @return boolean 66 | */ 67 | public function testFindByUnicodeReturnsAppropriateEmojiName() 68 | { 69 | $emojiName = $this->emoji->findByUnicode("\u{1F601}"); 70 | 71 | $realResult = array_flip($this->getEmojis()); 72 | 73 | $this->assertEquals($emojiName, $realResult["\u{1F601}"]); 74 | } 75 | 76 | /** 77 | * Test that a method that does not exist throws the right Exception 78 | * @expectedException Unicodeveloper\Emoji\Exceptions\UnknownMethod 79 | */ 80 | public function testNonexistentMethod() 81 | { 82 | $this->emoji->findAllEmojisInThisLifeMehn(); 83 | } 84 | 85 | /** 86 | * Test that findByAlias doesn't receive any argument 87 | * @expectedException Unicodeveloper\Emoji\Exceptions\IsNull 88 | */ 89 | public function testfindByAliasDoesntHaveAnArgument() 90 | { 91 | $this->emoji->findByAlias(); 92 | } 93 | 94 | /** 95 | * Test that findByName doesn't receive any argument 96 | * @expectedException Unicodeveloper\Emoji\Exceptions\IsNull 97 | */ 98 | public function testfindByNameDoesntHaveAnArgument() 99 | { 100 | $this->emoji->findByName(); 101 | } 102 | 103 | /** 104 | * Test that findByAlias gets an unkown emoji name 105 | * @expectedException Unicodeveloper\Emoji\Exceptions\UnknownEmoji 106 | */ 107 | public function testAWrongEmojiNameWasCalled() 108 | { 109 | $this->emoji->findByAlias('abracadabra'); 110 | } 111 | 112 | /** 113 | * Test that findByUnicode gets an unknown Unicode value 114 | * @expectedException Unicodeveloper\Emoji\Exceptions\UnknownUnicode 115 | */ 116 | public function testAWrongUnicodeValueWasCalled() 117 | { 118 | $this->emoji->findByUnicode("\u{1F611}"); 119 | } 120 | 121 | /** 122 | * Get the emojis from emoji.php 123 | * @return array 124 | */ 125 | private function getEmojis() 126 | { 127 | $result = require( __DIR__ . "/../src/Emojis/emoji.php"); 128 | 129 | return $result; 130 | } 131 | 132 | /** 133 | * Call protected/private method of a class. 134 | * 135 | * @param object &$object Instantiated object that we will run method on. 136 | * @param string $methodName Method name to call 137 | * @param array $parameters Array of parameters to pass into method. 138 | * 139 | * @return mixed Method return. 140 | */ 141 | private function invokeMethod(&$object, $methodName, array $parameters = array()) 142 | { 143 | $reflection = new ReflectionClass(get_class($object)); 144 | $method = $reflection->getMethod($methodName); 145 | $method->setAccessible(true); 146 | return $method->invokeArgs($object, $parameters); 147 | } 148 | 149 | } 150 | --------------------------------------------------------------------------------