Skip to content

Instantly share code, notes, and snippets.

@nch7
Created July 9, 2015 23:08
Show Gist options
  • Save nch7/05fb8d5dd44acb69cf6b to your computer and use it in GitHub Desktop.
Save nch7/05fb8d5dd44acb69cf6b to your computer and use it in GitHub Desktop.
<?php
trait GatewayTrait {
public function __call($name, $arguments) {
call_user_func_array([$this->repo, $name], $arguments);
}
}
class Gateway {
use GatewayTrait;
public function __construct() {
$this->repo = new Repo;
}
}
class Repo {
public function save($id, $arguments) {
var_dump($arguments);
}
}
$gateway = new Gateway;
$gateway->save(13,['foo'=>'bar']);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment