ContactForm::rules()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 9
ccs 2
cts 2
cp 1
crap 1
rs 10
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 10
    public function rules(): array
24
    {
25
        return [
26
            // name, email, subject and body are required
27 10
            [['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', \yii\captcha\CaptchaValidator::class],
32
        ];
33
    }
34
}
35