3
Let’s say I have the following class:
class animal{
    private $animal;
    private $som;
    function gato(){
        $this->animal = 'gato';
        return $this;
    }
    function cachorro(){
        $this->animal = 'cachorro';
        return $this;
    }
    function mia()
    {
        $this->som = 'miau';
        return $this;
    }
    function late()
    {
        $this->som = 'au au';
        return $this;
    }
}
From that point I could chain the methods in the following way
$animal = new animal();
$animal->gato()->mia();
$animal->cachorro()->late();
Or else:
$animal = new animal();
$animal->gato()->late();
$animal->cachorro()->mia();
As you can see above, by the code I said the "mia dog", but I would like to make certain methods inaccessible, that is, if I call the method "cat" I would like only the method "mia" to be accessible to chain.
I know that if I divide the methods into different classes it is easier to accomplish this task, even more organized, but I want to know if it is possible to perform such a task within the same class.
Possible duplicate of Require that one method must be after another?
– AnthraxisBR