Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. <?php
  2.  
  3. trait GatewayTrait {
  4. public function __call($name, $arguments) {
  5. call_user_func_array([$this->repo, $name], $arguments);
  6. }
  7. }
  8.  
  9. class Gateway {
  10. use GatewayTrait;
  11.  
  12. public function __construct() {
  13. $this->repo = new Repo;
  14. }
  15. }
  16.  
  17. class Repo {
  18. public function save($id, $arguments) {
  19. var_dump($arguments);
  20. }
  21. }
  22.  
  23. $gateway = new Gateway;
  24. $gateway->save(13,['foo'=>'bar']);
  25.  
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement