ChangeEmailAction   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A post() 0 17 3
1
<?php
2
3
namespace yrc\actions;
4
5
use common\forms\ChangeEmail;
0 ignored issues
show
Bug introduced by
The type common\forms\ChangeEmail was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use yrc\rest\Action as RestAction;
7
8
use yii\web\HttpException;
9
use Yii;
10
11
/**
12
 * Handles enabling and disabling of OTP
13
 * @class ChangeEmailAction
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. ( Ignorable by Annotation )

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

21
    public function post(/** @scrutinizer ignore-unused */ $params)

This check looks for 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->user->identityClass::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
}
40