|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace League\Emoji\Node; |
|
6
|
|
|
|
|
7
|
|
|
use League\Emoji\Dataset\Dataset; |
|
8
|
|
|
use League\Emoji\Dataset\Emoji as DatasetEmoji; |
|
9
|
|
|
use League\Emoji\EmojiConverter; |
|
10
|
|
|
use League\Emoji\Emojibase\EmojibaseSkinsInterface; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @property ?string $annotation |
|
14
|
|
|
* @property ?string $emoji |
|
15
|
|
|
* @property ?string $emoticon |
|
16
|
|
|
* @property ?int $gender |
|
17
|
|
|
* @property ?int $group |
|
18
|
|
|
* @property ?string $hexcode |
|
19
|
|
|
* @property ?string $htmlEntity |
|
20
|
|
|
* @property ?int $order |
|
21
|
|
|
* @property ?string $shortcode |
|
22
|
|
|
* @property string[] $shortcodes |
|
23
|
|
|
* @property Dataset $skins |
|
24
|
|
|
* @property ?int $subgroup |
|
25
|
|
|
* @property string[] $tags |
|
26
|
|
|
* @property ?string $text |
|
27
|
|
|
* @property int[] $tone |
|
28
|
|
|
* @property int $type |
|
29
|
|
|
* @property ?string $unicode |
|
30
|
|
|
* @property ?float $version |
|
31
|
|
|
* |
|
32
|
|
|
* @method string|null getShortcode(?array $exclude = null, bool $wrap = false) |
|
33
|
|
|
* @method string[] getShortcodes(?array $exclude = null) |
|
34
|
|
|
* @method string|\Stringable render() |
|
35
|
|
|
* @method void setRenderer(callable $renderer) |
|
36
|
|
|
*/ |
|
37
|
|
|
final class Emoji extends Node |
|
38
|
|
|
{ |
|
39
|
|
|
/** @var DatasetEmoji */ |
|
40
|
|
|
private $datasetEmoji; |
|
41
|
|
|
|
|
42
|
|
|
/** @var int */ |
|
43
|
|
|
private $parsedType; |
|
44
|
|
|
|
|
45
|
|
|
/** @var string */ |
|
46
|
|
|
private $parsedValue; |
|
47
|
|
|
|
|
48
|
117 |
|
public function __construct(int $parsedType, string $parsedValue, DatasetEmoji $emoji) |
|
49
|
|
|
{ |
|
50
|
117 |
|
parent::__construct($parsedValue); |
|
51
|
117 |
|
$this->datasetEmoji = $emoji; |
|
52
|
117 |
|
$this->parsedType = $parsedType; |
|
53
|
117 |
|
$this->parsedValue = $parsedValue; |
|
54
|
117 |
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @param mixed[] $arguments |
|
58
|
|
|
* |
|
59
|
|
|
* @return ?mixed |
|
60
|
|
|
*/ |
|
61
|
39 |
|
public function __call(string $name, array $arguments) |
|
62
|
|
|
{ |
|
63
|
|
|
/** @var callable $method */ |
|
64
|
39 |
|
$method = [$this->datasetEmoji, $name]; |
|
65
|
|
|
|
|
66
|
39 |
|
return \call_user_func_array($method, $arguments); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** @return ?mixed */ |
|
70
|
75 |
|
public function __get(string $name) |
|
71
|
|
|
{ |
|
72
|
75 |
|
return $this->datasetEmoji->$name; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
105 |
|
public function getParsedType(): int |
|
76
|
|
|
{ |
|
77
|
105 |
|
return $this->parsedType; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
24 |
|
public function getParsedValue(): string |
|
81
|
|
|
{ |
|
82
|
24 |
|
return $this->parsedValue; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
6 |
|
public function getSkin(int $tone = EmojibaseSkinsInterface::LIGHT_SKIN): ?self |
|
86
|
|
|
{ |
|
87
|
6 |
|
$skin = $this->datasetEmoji->getSkin($tone); |
|
88
|
|
|
|
|
89
|
6 |
|
if ($skin === null) { |
|
90
|
6 |
|
return null; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
3 |
|
$property = EmojiConverter::TYPES[$this->parsedType] ?? EmojiConverter::UNICODE; |
|
94
|
3 |
|
$value = (string) ($skin->$property ?? $this->parsedValue); |
|
95
|
|
|
|
|
96
|
3 |
|
return new self($this->parsedType, $value, $skin); |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
|