joypixels / joypixels/emoji-toolkit

(PHP) Cannot override `emojiVersion` or `emojiSize`

Open
#55 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
473
Forks
47
PR merge metrics
No merged PRs in 30d

Description

Hi there,

I would have expected this code:
```php
$client = new Client();
$client->emojiSize = 64;
echo $client->toImage('😀');
```

To produce `😀`, since the code is documented to say we can set `emojiSize`: `"available sizes are '32', '64', and '128'"`, but instead it produced `😀`,.
https://github.com/joypixels/emoji-toolkit/blob/7ed2733fac44df78fc7628cb51a0be5fb23066e3/lib/php/src/Client.php#L16

The issue is that since the `imagePathPNG` property is set in the constructor, it is too late use the `emojiSize` property on the `$client` instance.
https://github.com/joypixels/emoji-toolkit/blob/7ed2733fac44df78fc7628cb51a0be5fb23066e3/lib/php/src/Client.php#L36

A workaround is this, but I believe the code should act different, since it's not possible to customize it by setting the public property:
```php
$client = new class extends Client {
public $emojiSize = '64';
};
echo $client->toImage('😀');
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.