WalletTranslator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 3
dl 0
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A convertDTOToMangoPayWallet() 0 12 2
A convertMangoPayWalletToDTO() 0 11 1
1
<?php
2
/**
3
 * Created by Carl Owens ([email protected])
4
 * Company: PartFire Ltd (www.partfire.co.uk)
5
 * Copyright © 2016 PartFire Ltd. All rights reserved.
6
 *
7
 * User:    Carl Owens
8
 * Date:    28/11/2016
9
 * Time:    21:08
10
 * File:    WalletTranslator.php
11
 **/
12
namespace PartFire\MangoPayBundle\Models\DTOs\Translators;
13
14
use MangoPay\Wallet as MangoWallet;
15
use PartFire\MangoPayBundle\Models\DTOs\Wallet;
16
17
class WalletTranslator
18
{
19
    public function convertDTOToMangoPayWallet(Wallet $walletDto)
20
    {
21
        $mangoWallet = new MangoWallet();
22
        $mangoWallet->Tag = $walletDto->getTag();
23
        $mangoWallet->Owners = $walletDto->getOwenerIds();
24
        $mangoWallet->Description = $walletDto->getDescription();
25
        $mangoWallet->Currency = $walletDto->getCurrency();
26
        if ($walletDto->getId()) {
27
            $mangoWallet->Id = $walletDto->getId();
28
        }
29
        return $mangoWallet;
30
    }
31
32
    public function convertMangoPayWalletToDTO(MangoWallet $mangoWallet)
33
    {
34
        $walletDto = new Wallet();
35
        $walletDto->setTag($mangoWallet->Tag);
36
        $walletDto->setOwenerIds($mangoWallet->Owners);
37
        $walletDto->setDescription($mangoWallet->Description);
38
        $walletDto->setCurrency($mangoWallet->Currency);
39
        $walletDto->setId($mangoWallet->Id);
40
        $walletDto->setBalance($mangoWallet->Balance->Amount);
41
        return $walletDto;
42
    }
43
}
44