Test Failed
Push — master ( acc55b...606ce7 )
by Alexey
04:51
created

ParamValue::parse()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 15
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 4
eloc 12
c 1
b 0
f 1
nc 8
nop 0
dl 0
loc 15
rs 9.2
1
<?php
2
3
/**
4
 * Parser Object Value
5
 *
6
 * @author Alexey Krupskiy <[email protected]>
7
 * @link http://inji.ru/
8
 * @copyright 2015 Alexey Krupskiy
9
 * @license https://github.com/injitools/cms-Inji/blob/master/LICENSE
10
 */
11
12
namespace Migrations\Parser\Object;
13
14
class ParamValue extends \Migrations\Parser {
15
16
    public function parse() {
17
        $options = $this->param->options ? json_decode($this->param->options, true) : [];
0 ignored issues
show
Unused Code introduced by
$options is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
18
        $modelName = get_class($this->model);
19
        $cols = $modelName::$cols;
0 ignored issues
show
Unused Code introduced by
$cols is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
20
        $value = $this->data;
21
        if (is_array($value)) {
22
            $value = '';
23
        }
24
        $paramValue = \Ecommerce\Item\Param::get([[['item_id', $this->model->id], ['item_option_id', $this->param->value]]]);
25
        if (!$paramValue) {
26
            $paramValue = new \Ecommerce\Item\Param(['item_id' => $this->model->id, 'item_option_id' => $this->param->value]);
27
        }
28
        $paramValue->value = $value;
29
        $paramValue->save();
30
    }
31
}