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

OrderTransformer::transform()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.3142
c 0
b 0
f 0
cc 1
eloc 18
nc 1
nop 1
1
<?php
2
3
namespace WSW\SiftScience\Transformers\Events;
4
5
use WSW\SiftScience\Events\AbstractOrder;
6
use WSW\SiftScience\Support\Traits\Transformers\ObjectValues;
7
use WSW\SiftScience\Support\Traits\Transformers\Relationships;
8
use WSW\SiftScience\Transformers\AbstractTransformer;
9
10
/**
11
 * Class OrderTransformer
12
 *
13
 * @package WSW\SiftScience\Transformers\Events
14
 * @author Ronaldo Matos Rodrigues <[email protected]>
15
 */
16
class OrderTransformer extends AbstractTransformer
17
{
18
    use ObjectValues;
19
    use Relationships;
20
21
    /**
22
     * @param AbstractOrder $order
23
     *
24
     * @return array
25
     */
26
    public function transform(AbstractOrder $order)
27
    {
28
        return array_filter([
29
            '$type' => $order->getType(),
30
            '$api_key' => $order->getApiKey(),
31
            '$user_id' => $order->getUserId(),
32
            '$session_id' => $order->getSession(),
33
            '$order_id' => $order->getOrder(),
34
            '$user_email' => $this->email($order->getUserEmail()),
35
            '$amount' => $this->amount($order->getAmount()),
36
            '$currency_code' => $this->currency($order->getAmount()),
37
            '$billing_address' => $this->address($order->getBillingAddress()),
38
            '$payment_methods' => $this->paymentMethods($order->getPaymentMethods()),
39
            '$shipping_address' => $this->address($order->getShippingAddress()),
40
            '$expedited_shipping' => $order->isExpeditedShipping(),
41
            '$shipping_method' => $order->getShippingMethod(),
42
            '$items' => $this->items($order->getItems()),
43
            '$seller_user_id' => $order->getSellerUserId(),
44
            '$promotions' => $this->promotions($order->getPromotions())
45
        ]);
46
    }
47
}
48