Let say i have this class
class Test
{
method_a(){ return $this;}
method_b(){ return $this;}
method_c(){ return $this;}
}
$obj = new Test();
$obj->method_a()->method_b();
$obj->method_a()->method_c();
$obj->method_b()->method_c(); //i want to disallow this
How can i disallow method_b() chaining with method_c()
Edited:
Calling $obj->method_b() and follow by $obj->method_c() also disallow because i only want method_b chaining with method_a and method_c with other method
You could use a State Pattern and introduce State objects for each possible state in Test. When someone calls Method B, you change the state of Test internally to the StateB class and when someone calls Method C then you can raise an Exception.
See http://sourcemaking.com/design_patterns/state