Passed
Push — master ( 54c177...21af40 )
by Wilmer
01:54
created

ContactForm::rules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace TerabyteSoft\App\Basic\Forms;
4
5
use yii\base\Model;
6
7
/**
8
 * ContactForm.
9
 *
10
 * Model behind the contact form web application basic
11
 **/
12
class ContactForm extends Model
13
{
14
    public $name;
15
    public $email;
16
    public $subject;
17
    public $body;
18
    public $verifyCode;
19
20
    /**
21
     * rules.
22
     *
23
     * @return array the validation rules
24
     **/
25
    public function rules(): array
26
    {
27
        return [
28
            // name, email, subject and body are required
29
            [['name', 'email', 'subject', 'body'], 'required'],
30
            // email has to be a valid email address
31
            ['email', 'email'],
32
            // verifyCode needs to be entered correctly
33
            ['verifyCode', \Yiisoft\Yii\Captcha\CaptchaValidator::class],
34
        ];
35
    }
36
}
37