I’ve made a class and method just for search things on my website. It has too many parameters, the search parameters. My controller grabs data from forms and then pass to the model.
public function search($name, $age, $foo, ... $bar, $lorem) {
Are there any tips of this kind of method? Maybe a good practice about method with too much parameters.
Thanks.
EDIT:
parameters are for the search…
$name should search people with value of $name
$age should search people with value of $age
and so on…
something like the SQL Where clause.
Thanks again.
Darhazer and Zanathel already gave good answers, and I just want to show you one thing: setters with fluent interface. Only when all parameters are optional.
or
to create fluent interface, just write in setter’s body
return $this;