PromotionTransformer::transform()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 9
cts 9
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 1
crap 1
1
<?php
2
3
namespace WSW\SiftScience\Transformers\Entities;
4
5
use WSW\SiftScience\Entities\Promotion;
6
use WSW\SiftScience\Support\Traits\Transformers\Relationships;
7
use WSW\SiftScience\Transformers\AbstractTransformer;
8
9
/**
10
 * Class PromotionTransformer
11
 *
12
 * @package WSW\SiftScience\Transformers\Entities
13
 * @author Ronaldo Matos Rodrigues <[email protected]>
14
 */
15
class PromotionTransformer extends AbstractTransformer
16
{
17
    use Relationships;
18
19
    /**
20
     * @param Promotion $promotion
21
     *
22
     * @return array
23
     */
24 1
    public function transform(Promotion $promotion)
25
    {
26 1
        return array_filter([
27 1
            '$promotion_id' => $promotion->getId(),
28 1
            '$status' => $promotion->getStatus(),
29 1
            '$failure_reason' => $promotion->getFailureReason(),
30 1
            '$description' => $promotion->getDescription(),
31 1
            '$referrer_user_id' => $promotion->getReferrerUserId(),
32 1
            '$discount' => $this->discount($promotion->getDiscount()),
33 1
            '$credit_point' => $this->creditPoint($promotion->getCreditPoint())
34
        ]);
35
    }
36
}
37