/** * @param $invoice * @param $type * @param null $payment */ private function sendEmails($invoice, $type, $payment = null) { foreach ($invoice->account->users as $user) { if ($user->{"notify_{$type}"}) { $this->userMailer->sendNotification($user, $invoice, $type, $payment); } } }