Completed
Push — master ( e3ed33...61d114 )
by
unknown
04:23
created

Price::map()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
ccs 0
cts 12
cp 0
rs 9.4286
cc 2
eloc 10
nc 2
nop 1
crap 6
1
<?php
2
3
namespace Iris\Mapping;
4
5
class Price extends Base
6
{
7
    /**
8
     * {@inheritdoc}
9
     */
10 1
    public function assign(array $externalData)
11
    {
12 1
        $priceCollection = new \Iris\Transfer\Catalog\ConfigCollection;
13 1
        foreach ($externalData as $data) {
14 1
            $price = new \Iris\Transfer\Catalog\Config([
0 ignored issues
show
Unused Code introduced by
$price 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...
15 1
                'sku'             => $data['sku'],
16 1
                'price'           => $data['price'],
17 1
                'special_price'   => $data['special_price'],
18 1
                'specialFromDate' => $data['special_from_date'],
19 1
                'specialToDate'   => $data['special_to_date']
20 1
            ]);
21 1
        }
22
23 1
        return $priceCollection;
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function map($internalData)
30
    {
31
        $externalData = ['items' => []];
32
33
        foreach ($internalData->getItemCollection() as $item) {
34
            $externalData['items'][] = [
35
                'sku'             => $item->getSku(),
36
                'price'           => $item->getPrice(),
37
                'special_price'   => $item->getSpecialPrice(),
38
                'specialFromDate' => $item->getSpecialFromDate(),
39
                'specialToDate'   => $item->getSpecialToDate()
40
            ];
41
        }
42
43
        return $externalData;
44
    }
45
}
46