Passed
Push — master ( 7a227f...bebcd3 )
by Alexander
09:27 queued 03:41
created

ContactForm   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 17
c 0
b 0
f 0
dl 0
loc 30
ccs 9
cts 9
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 7 1
A attributeLabels() 0 7 1
A formName() 0 3 1
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