Passed
Pull Request — master (#186)
by Alexander
04:24
created

ContactForm::formName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Contact;
6
7
use Yiisoft\Form\FormModel;
8
use Yiisoft\Validator\Rule\Email;
9
use Yiisoft\Validator\Rule\Required;
10
11
final class ContactForm extends FormModel
12
{
13
    private string $username = '';
0 ignored issues
show
introduced by
The private property $username is not used, and could be removed.
Loading history...
14
    private string $email = '';
0 ignored issues
show
introduced by
The private property $email is not used, and could be removed.
Loading history...
15
    private string $subject = '';
0 ignored issues
show
introduced by
The private property $subject is not used, and could be removed.
Loading history...
16
    private string $body = '';
0 ignored issues
show
introduced by
The private property $body is not used, and could be removed.
Loading history...
17
    private ?array $attachFiles = null;
0 ignored issues
show
introduced by
The private property $attachFiles is not used, and could be removed.
Loading history...
18
19 6
    public function attributeLabels(): array
20
    {
21
        return [
22 6
            'username' => 'Username',
23
            'email' => 'Email',
24
            'subject' => 'Subject',
25
            'body' => 'Body',
26
        ];
27
    }
28
29 6
    public function formName(): string
30
    {
31 6
        return 'ContactForm';
32
    }
33
34 6
    public function rules(): array
35
    {
36
        return [
37 6
            'username' => [new Required()],
38 6
            'email' => [new Required(), new Email()],
39 6
            'subject' => [new Required()],
40 6
            'body' => [new Required()],
41
        ];
42
    }
43
}
44