Skip to content

Instantly share code, notes, and snippets.

@rizqidjamaluddin
Created October 16, 2014 11:31
Show Gist options
  • Save rizqidjamaluddin/909d973e2fb8a7346af2 to your computer and use it in GitHub Desktop.
Save rizqidjamaluddin/909d973e2fb8a7346af2 to your computer and use it in GitHub Desktop.
An experimental idea of an endpoint schema with translation logic
class MessageSchema extends EndpointSchema
{
public function bridge () {
return [
'message' => new Parameter([
'get' => function($e) {
return $e->getMessage();
}
'set' => function($i, $e) {
return $e->setMessage($i);
}
]),
'destination' => new Parameter([
'get' => function($e) {
return $e->getRecipient();
}
'set' => function($i, $e) {
return $e->setRecipient($i);
}
]),
'sender' => new Parameter([
'set' => function($i, $e) {
return $e->setSender($i);
}
]),
'sent_at' => new Parameter([
'get' => function($e) {
return $e->created_at;
}
])
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment