Completed
Push — master ( fb0370...84a128 )
by Ronaldo
03:03
created

DiscountTransformer   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 5
dl 0
loc 17
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 9 1
1
<?php
2
3
namespace WSW\SiftScience\Transformers;
4
5
use WSW\SiftScience\Entities\Discount;
6
7
/**
8
 * Class DiscountTransformer
9
 *
10
 * @package WSW\SiftScience\Transformers
11
 * @author Ronaldo Matos Rodrigues <[email protected]>
12
 */
13
class DiscountTransformer extends AbstractTransformer
14
{
15
    /**
16
     * @param Discount $discount
17
     *
18
     * @return array
19
     */
20
    public function transform(Discount $discount)
21
    {
22
        return array_filter([
23
            '$percentage_off' => $discount->getPercentage()->getPercent(),
24
            '$amount' => $discount->getAmount()->getMicros(),
25
            '$currency_code' => $discount->getAmount()->getCurrency()->getCode(),
26
            '$minimum_purchase_amount' => $discount->getMinimumPurchaseAmount()->getMicros()
27
        ]);
28
    }
29
}
30