Is the following method considered to be doing one thing only?
I'm wondering about that since it takes an optional argument.
public function findErrors($name = null)
{
if ($name) {
return isset($this->errors[$name]) ? $this->errors[$name] : [];
}
return $this->errors ?: [];
}
If not, would it be better / matter to have it separated like the following:
public function findErrors()
{
return $this->errors ?: [];
}
public function findErrorsOf($name)
{
return isset($this->errors[$name]) ? $this->errors[$name] : [];
}