Test Failed
Pull Request — master (#242)
by Alexander
04:45
created

ContactForm   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getAttributeLabels() 0 7 1
A getRules() 0 7 1
A getFormName() 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\Form\HtmlOptions\EmailHtmlOptions;
9
use Yiisoft\Form\HtmlOptions\RequiredHtmlOptions;
10
use Yiisoft\Validator\Rule\Email;
11
use Yiisoft\Validator\Rule\Required;
12
13
final class ContactForm extends FormModel
14
{
15
    private string $name = '';
0 ignored issues
show
introduced by
The private property $name is not used, and could be removed.
Loading history...
16
    private string $email = '';
0 ignored issues
show
introduced by
The private property $email is not used, and could be removed.
Loading history...
17
    private string $subject = '';
0 ignored issues
show
introduced by
The private property $subject is not used, and could be removed.
Loading history...
18
    private string $body = '';
0 ignored issues
show
introduced by
The private property $body is not used, and could be removed.
Loading history...
19
    private ?array $attachFiles = null;
0 ignored issues
show
introduced by
The private property $attachFiles is not used, and could be removed.
Loading history...
20
21 6
    public function getAttributeLabels(): array
22
    {
23
        return [
24 6
            'name' => 'Name',
25
            'email' => 'Email',
26
            'subject' => 'Subject',
27
            'body' => 'Body',
28
        ];
29
    }
30
31 6
    public function getFormName(): string
32
    {
33 6
        return 'ContactForm';
34
    }
35
36 6
    public function getRules(): array
37
    {
38
        return [
39 6
            'name' => [new RequiredHtmlOptions(new Required())],
40 6
            'email' => [new RequiredHtmlOptions(new Required()), new EmailHtmlOptions(new Email())],
41 6
            'subject' => [new RequiredHtmlOptions(new Required())],
42 6
            'body' => [new RequiredHtmlOptions(new Required())],
43
        ];
44
    }
45
}
46