Skip to content

Make it unnecessary to manually set the type in the Message model. #733

@eucyt

Description

@eucyt

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:

  1. Change the code generation logic so that the constructor automatically sets its own discriminator. (recomended)
  2. Make it internally call fromAssocArray.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions