Completed
Push — master ( 84a128...7da2fe )
by Ronaldo
07:05
created

ItemTransformer::transform()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 14
nc 1
nop 1
1
<?php
2
3
namespace WSW\SiftScience\Transformers\Entities;
4
5
use WSW\SiftScience\Entities\Item;
6
use WSW\SiftScience\Support\Traits\Transformers\ObjectValues;
7
use WSW\SiftScience\Transformers\AbstractTransformer;
8
9
/**
10
 * Class ItemTransformer
11
 *
12
 * @package WSW\SiftScience\Transformers\Entities
13
 * @author Ronaldo Matos Rodrigues <[email protected]>
14
 */
15
class ItemTransformer extends AbstractTransformer
16
{
17
    use ObjectValues;
18
19
    /**
20
     * @param Item $item
21
     *
22
     * @return array
23
     */
24
    public function transform(Item $item)
25
    {
26
        return array_filter([
27
            '$item_id' => $item->getId(),
28
            '$product_title' => $item->getTitle(),
29
            '$price' => $this->amount($item->getPrice()),
30
            '$currency_code' => $this->amount($item->getPrice()),
31
            '$quantity' => $item->getQuantity(),
32
            '$upc' => $item->getUpc(),
33
            '$sku' => $item->getSku(),
34
            '$brand' => $item->getBrand(),
35
            '$manufacturer' => $item->getManufacturer(),
36
            '$category' => $item->getCategory(),
37
            '$tags' => $item->getTags(),
38
            '$color' => $item->getColor()
39
        ]);
40
    }
41
}
42