Completed
Push — master ( 8ea8de...59eb2e )
by Charles
01:52
created

ChangeEmailAction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 25
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A post() 0 18 3
1
<?php
2
3
namespace yrc\actions;
4
5
use app\forms\ChangeEmail;
6
use yrc\rest\Action as RestAction;
7
8
use yii\web\HttpException;
9
use Yii;
10
11
/**
12
 * @class ChangeEmailAction
13
 * Handles enabling and disabling of OTP
14
 */
15
class ChangeEmailAction extends RestAction
16
{
17
    /**
18
     * Allows the user to change the email address associated to their account
19
     * @return boolean
20
     */
21
    public function post($params)
0 ignored issues
show
Unused Code introduced by
The parameter $params is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
22
    {
23
        $model = new ChangeEmail;
24
        
25
        if ($model->load(['ChangeEmail' => Yii::$app->request->post()])) {
26
            $model->setUser(Yii::$app->yrc->userClass::findOne([
27
                'id' => Yii::$app->user->id
28
            ]));
29
30
            if ($model->change()) {
31
                return true;
32
            }
33
34
            throw new HttpException(400, \json_encode($model->getErrors()));
35
        }
36
            
37
        return false;
38
    }
39
}