Test Failed
Pull Request — master (#476)
by
unknown
03:09
created

SignupForm::passwordVerifyRules()   A

Complexity

Conditions 4
Paths 1

Size

Total Lines 19
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 12
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 19
ccs 10
cts 10
cp 1
crap 4
rs 9.8666
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Auth\Form;
6
7
use Yiisoft\Form\FormModel;
8
use Yiisoft\Translator\TranslatorInterface;
9
use Yiisoft\Validator\Rule\Equal;
10
use Yiisoft\Validator\Rule\Required;
11
12
final class SignupForm extends FormModel
13
{
14
    private string $login = '';
15
    private string $password = '';
16
    private string $passwordVerify = '';
0 ignored issues
show
introduced by
The private property $passwordVerify is not used, and could be removed.
Loading history...
17
18
    public function __construct(
19
        private TranslatorInterface $translator
20
    ) {
21 5
        parent::__construct();
22
    }
23 5
24
    public function getAttributeLabels(): array
25 5
    {
26 5
        return [
27
            'email' => $this->translator->translate('layout.login'),
28
            'password' => $this->translator->translate('layout.password'),
29 5
            'passwordVerify' => $this->translator->translate('layout.password-verify'),
30
        ];
31
    }
32 5
33 5
    public function getFormName(): string
34 5
    {
35
        return 'Signup';
36
    }
37
38 5
    public function getLogin(): string
39
    {
40 5
        return $this->login;
41
    }
42
43
    public function getPassword(): string
44
    {
45
        return $this->password;
46
    }
47
48
    public function getRules(): array
49
    {
50
        return [
51
            'login' => [new Required()],
52
            'password' => [new Required()],
53 5
            'passwordVerify' => [
54
                new Required(),
55
                new Equal(targetValue: $this->password,
56 5
                    message: $this->translator->translate('validator.password.not.match')),
57 5
            ],
58 5
        ];
59
    }
60
}
61