i wonder how php can achieve like below function design:
Class->func()->func()
Here is the laravel validate example.
$validator->after(function($validator)
{
if ($this->somethingElseIsInvalid())
{
**$validator->errors()->add('field', 'Something is wrong with this field!');**
}
});
Is the after() do the magic work here?
And how to create my own code that can behave like this.
return $this;which returns the object and gives you the possibility to doclass->func()->func()->func()