ResendForm::resend()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 12
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 12
loc 12
c 0
b 0
f 0
rs 9.4285
ccs 0
cts 11
cp 0
cc 3
eloc 7
nc 3
nop 0
crap 12
1
<?php
2
3
namespace inblank\activeuser\models\forms;
4
5
use inblank\activeuser\traits\CommonTrait;
6
use yii;
7
use yii\base\Model;
8
9
class ResendForm extends Model
10
{
11
    use CommonTrait;
12
13
    /**
14
     * @var string user email for register
15
     */
16
    public $email;
17
18
    /** @inheritdoc */
19
    public function attributeLabels()
20
    {
21
        return [
22
            'email' => Yii::t('activeuser_general', 'Email'),
23
        ];
24
    }
25
26
    /**
27
     * @inheritdoc
28
     */
29
    public function rules()
30
    {
31
        return [
32
            ['email', 'required'],
33
            ['email', 'email'],
34
        ];
35
    }
36
37
    /**
38
     * Resend
39
     * @return bool
40
     * @throws yii\base\InvalidConfigException
41
     */
42 View Code Duplication
    public function resend()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
43
    {
44
        if (!$this->validate()) {
45
            return false;
46
        }
47
        /** @var \inblank\activeuser\models\User $user */
48
        $user = Yii::createObject(self::di('User'))->findOne(['email' => $this->email]);
0 ignored issues
show
Documentation introduced by
self::di('User') is of type *, but the function expects a callable.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
49
        if ($user) {
50
            $user->resend();
51
        }
52
        return true;
53
    }
54
}
55