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

ActivationAction::post()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
dl 14
loc 14
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 1
1
<?php
2
3
namespace yrc\actions;
4
5
use app\forms\Activation;
6
use yrc\rest\Action as RestAction;
7
8
use yii\web\HttpException;
9
use Yii;
10
11
/**
12
 * @class ActivationAction
13
 * Handles token refresh
14
 */
15 View Code Duplication
class ActivationAction extends RestAction
0 ignored issues
show
Duplication introduced by
This class 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...
16
{
17
    /**
18
     * Activates a user given their activation token
19
     * @return mixed
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 Activation;
24
        
25
        if ($model->load(['Activation' => Yii::$app->request->post()])) {
26
            if ($model->validate()) {
27
                return $model->activate();
28
            }
29
30
            throw new HttpException(400, \json_encode($model->getErrors()));
31
        }
32
            
33
        return false;
34
    }
35
}