Created
December 25, 2014 12:41
-
-
Save jk/e7ba80e288f10e499cd2 to your computer and use it in GitHub Desktop.
Generate cache key from method invocation
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
<?php | |
class MyClass { | |
public function myFunction($myParam) { | |
$callee = debug_backtrace(null, 2)[1]; | |
$method_string = $callee['class'].$callee['type'].$callee['function'].'('.implode(', ', $callee['args']).')'; | |
return $method_string; | |
} | |
} | |
class Runner { | |
public function run($param1, $param2) { | |
$c = new MyClass(); | |
$r = $c->myFunction('test'); | |
var_dump($r); | |
} | |
} | |
$c = new Runner(); | |
$c->run('value1', 'value2'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment