PHP: Prevent chained method from returning?
- by Industrial
Hi,
I am having some headaches regarding method chaining for a quite simple PHP class that returns a value, which sometimes need to go through a decryption process:
$dataset = new Datacontainer;
$key = $dataset->get('key');
$key2 = $dataset->get('key')->decrypt();
The get method is where the return lives. So the call to the decrypt method on the second row isn't going to work in its current state.
Can I do something to setup the get method to return only when nothing is chained to it, or what would be the best way to re-factor this code?