Currently, when instantiating a model that inherits from Message, you need to explicitly set the type.
$message = (new TextMessage())
->setType(\LINE\Constants\MessageType::TEXT) // this is redundant.
->setText('hello!');
However, this value is obvious from the subclass itself, so having to set it manually is redundant.
Let’s make it set automatically.
Two possible approaches:
- Change the code generation logic so that the constructor automatically sets its own discriminator. (recomended)
- Make it internally call fromAssocArray.
Currently, when instantiating a model that inherits from Message, you need to explicitly set the type.
However, this value is obvious from the subclass itself, so having to set it manually is redundant.
Let’s make it set automatically.
Two possible approaches: