Created
October 16, 2014 11:31
-
-
Save rizqidjamaluddin/909d973e2fb8a7346af2 to your computer and use it in GitHub Desktop.
An experimental idea of an endpoint schema with translation logic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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