| Total Complexity | 6 |
| Total Lines | 62 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class Serializer implements Serializable |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var Transaction |
||
| 12 | */ |
||
| 13 | protected $transaction; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var string |
||
| 17 | */ |
||
| 18 | protected $action; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | protected $operation; |
||
| 24 | |||
| 25 | public function __construct(Transaction $transaction, $action, $operation) |
||
| 26 | { |
||
| 27 | $this->transaction = $transaction; |
||
| 28 | $this->action = $action; |
||
| 29 | $this->operation = $operation; |
||
| 30 | } |
||
| 31 | |||
| 32 | public function serialize() |
||
| 33 | { |
||
| 34 | $response = [ |
||
| 35 | 'identificacao' => urlencode((string) $this->transaction->getIpag()->getAuthentication()->getIdentification()), |
||
| 36 | 'transId' => urlencode((string) $this->transaction->getTid()), |
||
| 37 | 'retorno_tipo' => urlencode('xml'), |
||
| 38 | ]; |
||
| 39 | |||
| 40 | $amount = $this->transaction->getOrder()->getAmount(); |
||
| 41 | if (!empty($amount)) { |
||
| 42 | $response['valor'] = $amount; |
||
| 43 | } |
||
| 44 | |||
| 45 | return $response; |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @return Transaction |
||
| 50 | */ |
||
| 51 | public function getTransaction() |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @return string |
||
| 58 | */ |
||
| 59 | public function getAction() |
||
| 60 | { |
||
| 61 | return $this->action; |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @return string |
||
| 66 | */ |
||
| 67 | public function getOperation() |
||
| 70 | } |
||
| 71 | } |
||
| 72 |