Passed
Push — master ( 672c08...9a8256 )
by Anton
02:40
created

UpdateRelationshipAction::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 10
rs 9.4285
c 1
b 0
f 1
cc 2
eloc 4
nc 2
nop 2
1
<?php
2
/**
3
 * @link http://www.stombox.com/
4
 * @copyright Copyright (c) 2015 Stombox LLC
5
 * @license http://www.stombox.com/license/
6
 */
7
8
namespace tuyakhov\jsonapi;
9
10
11
use yii\rest\Action;
12
use yii\web\ServerErrorHttpException;
13
14
class UpdateRelationshipAction extends Action
15
{
16
    public function run($id, $name)
0 ignored issues
show
Unused Code introduced by
The parameter $name 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...
17
    {
18
        $model = $this->findModel($id);
19
20
        if ($model instanceof ResourceInterface) {
0 ignored issues
show
Unused Code introduced by
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
21
22
        }
23
24
        throw new ServerErrorHttpException('Failed to update the relationship for unknown reason.');
25
    }
26
}