Can anyone tell me if it's possible to call a php object's method based on the success of a test? For example below...
Normal usage:
$obj = new obj;
$obj->call()
->successive()
->methods();
Running test to see if method should be called:
$obj = new obj;
$obj->call()
( if ($a) ? ->successive() : '')
->methods();
Is there any way to make the second example above work? Or another way to achieve the same result? Thanks.
Perhaps?
$obj = new obj;
$temp = $obj->call();
if ($a) {
$temp = $temp->successive();
}
$temp->methods();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With