Completed
Pull Request — master (#6)
by Rafael
02:41
created

SimpleCollection   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 43
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A assign() 0 21 1
A map() 0 11 2
1
<?php
2
3
namespace Iris\Mapping;
4
5
class SimpleCollection extends Base
6
{
7
    /**
8
     * {@inheritdoc}
9
     */
10
    public function assign($externalData)
11
    {
12
        $order = new \Iris\Transfer\Catalog\ConfigCollection();
13
        $config = [
0 ignored issues
show
Unused Code introduced by
$config 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...
14
           'sku'              => $c['sku'],
0 ignored issues
show
Bug introduced by
The variable $c does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
15
           'variation'        => $c['variation'],
16
           'brand'            => $c['brand'],
17
           'color'            => $c['color'],
18
           'gender'           => $c['gender'],
19
           'color_family'     => $c['color_family'],
20
           'box_height'       => $c['box_height'],
21
           'box_width'        => $c['box_width'],
22
           'box_length'       => $c['box_length'],
23
           'weight'           => $c['weight'],
24
           'color_name_brand' => $c['color_name_brand'],
25
           'quantity'         => $c['quantity'],
26
           'barcode_ean'      => $c['barcode_ean']
27
        ];
28
29
        return $order;
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     * @param \Iris\Transfer\Catalog\SimpleCollection $internalData
35
     */
36
    public function map($internalData)
37
    {
38
        $externalData = [];
39
        foreach ($internalData as $simple) {
40
            $externalData[] = [
41
                'sku' => $simple->getSku()
42
            ];
43
        }
44
45
        return $externalData;
46
    }
47
}
48