Skip to content

(PHP) Cannot override emojiVersion or emojiSize聽#55

Description

@tadhgboyle

Hi there,

I would have expected this code:

$client = new Client();
$client->emojiSize = 64;
echo $client->toImage('馃榾');

To produce <img class="joypixels" alt="馃榾" title=":grinning:" src="https://cdn.jsdelivr.net/joypixels/assets/7.0/png/unicode/64/1f600.png">, since the code is documented to say we can set emojiSize: "available sizes are '32', '64', and '128'", but instead it produced <img class="joypixels" alt="馃榾" title=":grinning:" src="https://cdn.jsdelivr.net/joypixels/assets/7.0/png/unicode/32/1f600.png">,.

public $emojiSize = '32'; // available sizes are '32', '64', and '128'

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.

$this->imagePathPNG = $this->imagePathPNG . '/' . $this->emojiVersion . '/png/unicode/' . $this->emojiSize . '/';

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:

$client = new class extends Client {
    public $emojiSize = '64';
};
echo $client->toImage('馃榾');

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions