我在我的一些 MVC 网站中建立了一个模型来帮助发送电子邮件,通常我会做这样的事情
$mail = new Mail_Model;
$mail->to('me@somewhere.com');
$mail->from('you@somewhere.com');
$mail->subject('hello');
$mail->body('hello how are you');
$mail->send();
我知道该模型旨在对数据进行建模 - 那么我所做的是否违反了这一点?它应该是一个助手类吗?就像是...
Mail::send('me@somewhere.com', 'you@somewhere.com', 'hello', 'hello how are you');
第二个对我来说读起来不太好……当然,我可以传入一个带有命名键的数组以使其更具可读性。
那么我的邮件模型是否违反了 MVC 范式中的模型?