jeudi 2 juin 2016

Builder Design Pattern: Parameter of second method within the first

How can I use the parameter of the second() method when calling the first()?

class SomeClass {

    public function first($first_value)
    {
        Event::listen($first_value, function($event) {

            $second_value; <-- how to get that?

        });

        return $this;

    } 

    public function second($second_value)
    {
        // how to set the value for ->first() ?
    }
}

->first('App\Event\SomeEvent')->second(10);

Aucun commentaire:

Enregistrer un commentaire