So I am writing a PHP class at the moment to help make construction of SQL statements easier. I am writing them so that each method returns an instance of the object (return $this
) in order to enable method chaining.
Is it possible to test whether a method being called is a part of a method chain and which methods have been executed already in the method chain? For example, in the below code, I would like the 'from' method to test whether it was called as part of a chain with the select()
method directly before it.
$object->select('john', 'chris')->from('people');
Thanks in advance!