Create   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 56
ccs 37
cts 37
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getHttpMethod() 0 4 1
A exportContextData() 0 42 3
1
<?php
2
3
namespace GFG\DTOMarketplace\Context\Venture\Product;
4
5
use GFG\DTOMarketplace\Context\Base;
6
use GFG\DTOMarketplace\DataWrapper\Catalog\Simple;
7
8
class Create extends Base
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13 1
    public function getHttpMethod()
14
    {
15 1
        return 'post';
16
    }
17
18
    /**
19
     * {@inheritdoc}
20
     */
21 1
    public function exportContextData()
22
    {
23 1
        $dataWrapper      = $this->getDataWrapper();
24 1
        $simpleCollection = [];
25 1
        $imageCollection  = [];
26
27
        /** @var Simple $simple */
28 1
        foreach ($dataWrapper->getSimpleCollection() as $simple) {
29 1
            $simpleCollection[] = [
30 1
                'sku'         => $simple->getSku(),
31 1
                'partner_sku' => $simple->getPartnerSku(),
32 1
                'venture_product_id' => $simple->getVentureProductId(),
33 1
                'variation'   => $simple->getVariation(),
34 1
                'quantity'    => $simple->getQuantity(),
35 1
                'ean'         => $simple->getEan(),
36 1
                'attributes'  => $simple->getAttributes()
37 1
            ];
38 1
        }
39
40 1
        foreach ($dataWrapper->getImageCollection() as $image) {
41 1
            $imageCollection[] = [
42 1
                'url'      => $image->getUrl(),
43 1
                'position' => $image->getPosition()
44 1
            ];
45 1
        }
46
47 1
        return $this->prepareExport([
48 1
            'sku'               => $dataWrapper->getSku(),
49 1
            'partner_sku'       => $dataWrapper->getPartnerSku(),
50 1
            'name'              => $dataWrapper->getName(),
51 1
            'description'       => $dataWrapper->getDescription(),
52 1
            'brand'             => $dataWrapper->getBrand(),
53 1
            'price'             => $dataWrapper->getPrice(),
54 1
            'special_price'     => $dataWrapper->getSpecialPrice(),
55 1
            'special_from_date' => $dataWrapper->getSpecialFromDate(),
56 1
            'special_to_date'   => $dataWrapper->getSpecialToDate(),
57 1
            'attributes'        => $dataWrapper->getAttributes(),
58 1
            'attribute_set'     => $dataWrapper->getAttributeSet(),
59 1
            'image_collection'  => $imageCollection,
60
            'simple_collection' => $simpleCollection
61 1
        ]);
62
    }
63
}
64