Total Complexity | 4 |
Total Lines | 53 |
Duplicated Lines | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | class ContactForm extends Model |
||
12 | { |
||
13 | public $name; |
||
14 | public $email; |
||
15 | public $subject; |
||
16 | public $body; |
||
17 | public $verifyCode; |
||
18 | |||
19 | |||
20 | /** |
||
21 | * @return array the validation rules. |
||
22 | */ |
||
23 | public function rules() |
||
24 | { |
||
25 | return [ |
||
26 | // name, email, subject and body are required |
||
27 | [['name', 'email', 'subject', 'body'], 'required'], |
||
28 | // email has to be a valid email address |
||
29 | ['email', 'email'], |
||
30 | // verifyCode needs to be entered correctly |
||
31 | ['verifyCode', 'captcha'], |
||
32 | ]; |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * @return array customized attribute labels |
||
37 | */ |
||
38 | public function attributeLabels() |
||
39 | { |
||
40 | return [ |
||
41 | 'verifyCode' => 'Verification Code', |
||
42 | ]; |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * Sends an email to the specified email address using the information collected by this model. |
||
47 | * @param string $email the target email address |
||
48 | * @return bool whether the model passes validation |
||
49 | */ |
||
50 | public function contact($email) |
||
64 | } |
||
65 | } |
||
66 |