Passed
Push — master ( 525c1b...c21c1f )
by Wilmer
01:55
created

ResetPasswordForm::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace app\basic\forms;
4
5
use app\basic\models\UserModels;
6
use yii\base\Model;
7
use yii\helpers\Yii;
8
9
class ResetPasswordForm extends Model
10
{
11
	public $password;
12
13
	/**
14
	 * {@inheritdoc}
15
	 **/
16
	public function rules()
17
	{
18
		return [
19
			['password', 'required'],
20
			['password', 'string', 'min' => 6],
21
		];
22
	}
23
24
	/**
25
	 * atributeLabels.
26
	 *
27
	 * Translate Atribute Labels.
28
	 **/
29
	public function attributeLabels()
30
	{
31
		return [
32
			'password' => Yii::getApp()->t('basic', 'Password'),
0 ignored issues
show
Deprecated Code introduced by
The function yii\helpers\BaseYii::getApp() has been deprecated: 3.0.0 Use DI instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

32
			'password' => /** @scrutinizer ignore-deprecated */ Yii::getApp()->t('basic', 'Password'),

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
33
		];
34
	}
35
36
	/**
37
	 * Resets password.
38
	 *
39
	 * @return bool if password was reset.
40
	 **/
41
	public function resetPassword()
42
	{
43
    	$user = new UserModels;
44
		$user->setPassword($this->password);
45
		$user->removePasswordResetToken();
46
47
		return $user->save(false);
48
	}
49
}
50