mardi 14 juin 2022

Is this class a builder?

Thanks to this class:

https://github.com/WebPajooh/TeleBot/blob/master/src/InlineKeyboard.php

I can build keyboards step by step:

$keyboard = new InlineKeyboard()
    ->addCallbackButton('Start', 'start_callback')
    ->addCallbackButton('Help', 'help_callback')
    ->addUrlButton('FAQ', 'https://example.com/faq')
    ->get();

The output of get() method is an object encoded by json_encode().

My question is:

  1. Can we consider this class a builder?
  2. If answer is no, why?
  3. Its output is not an object, but a string; does it mean that it is not implementing builder pattern?

Aucun commentaire:

Enregistrer un commentaire