Voucher   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 108
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 108
rs 10
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A setOrder() 0 4 1
A setSeller() 0 4 1
A getCustomer() 0 3 1
A __construct() 0 3 1
A getSeller() 0 3 1
A getOrder() 0 3 1
A setCustomer() 0 4 1
A schema() 0 7 1
1
<?php
2
3
namespace Ipag\Sdk\Model;
4
5
use Ipag\Sdk\Model\Schema\Schema;
6
use Ipag\Sdk\Model\Schema\SchemaBuilder;
7
8
/**
9
 * Voucher Class
10
 *
11
 * Classe responsável por representar o recurso Voucher.
12
 */
13
class Voucher extends Model
14
{
15
16
    /**
17
     *  @param array $data
18
     *  array de dados do Voucher.
19
     *
20
     *  + [`'order'`] array (opcional) dos dados do Order.
21
     *  + &emsp; [`'order_id'`] string.
22
     *  + &emsp; [`'amount'`] float.
23
     *  + &emsp; [`'created_at'`] string.
24
     *  + &emsp; [`'callback_url'`] string.
25
     *
26
     *  + [`'seller'`] array (opcional) dos dados do Seller.
27
     *  + &emsp; [`'cpf_cnpj'`] string (opcional).
28
     *
29
     *  + [`'customer'`] array (opcional) dos dados do Customer.
30
     *  + &emsp; [`'name'`] string.
31
     *  + &emsp; [`'email'`] string (opcional).
32
     *  + &emsp; [`'phone'`] string (opcional).
33
     *  + &emsp; [`'cpf_cnpj'`] string (opcional).
34
     *  + &emsp; [`'birthdate'`] string (opcional) {`Formato: Y-m-d`}.
35
     *  + &emsp; [`'address'`] array (opcional) dos dados do Address.
36
     *  + &emsp;&emsp; [`'street'`] string (opcional).
37
     *  + &emsp;&emsp; [`'number'`] string (opcional).
38
     *  + &emsp;&emsp; [`'district'`] string (opcional).
39
     *  + &emsp;&emsp; [`'city'`] string (opcional).
40
     *  + &emsp;&emsp; [`'state'`] string (opcional).
41
     *  + &emsp;&emsp; [`'zipcode'`] string (opcional).
42
     */
43
    public function __construct(?array $data = [])
44
    {
45
        parent::__construct($data);
46
    }
47
48
    protected function schema(SchemaBuilder $schema): Schema
49
    {
50
        $schema->has('order', Order::class)->nullable();
51
        $schema->has('seller', Seller::class)->nullable();
52
        $schema->has('customer', Customer::class)->nullable();
53
54
        return $schema->build();
55
    }
56
57
    /**
58
     * Retorna o objeto `Order` associado ao `Voucher`.
59
     *
60
     * @return Order|null
61
     */
62
    public function getOrder(): ?Order
63
    {
64
        return $this->get('order');
65
    }
66
67
    /**
68
     * Seta o objeto `Order` associado ao `Voucher`.
69
     *
70
     * @param Order|null $order
71
     * @return self
72
     */
73
    public function setOrder(?Order $order = null): self
74
    {
75
        $this->set('order', $order);
76
        return $this;
77
    }
78
79
    /**
80
     * Retorna o objeto `Seller` associado ao `Voucher`.
81
     *
82
     * @return Seller|null
83
     */
84
    public function getSeller(): ?Seller
85
    {
86
        return $this->get('seller');
87
    }
88
89
    /**
90
     * Seta o objeto `Seller` associado ao `Voucher`.
91
     *
92
     * @param Seller|null $seller
93
     * @return self
94
     */
95
    public function setSeller(?Seller $seller = null): self
96
    {
97
        $this->set('seller', $seller);
98
        return $this;
99
    }
100
101
    /**
102
     * Retorna o objeto `Customer` associado ao `Voucher`.
103
     *
104
     * @return Customer|null
105
     */
106
    public function getCustomer(): ?Customer
107
    {
108
        return $this->get('customer');
109
    }
110
111
    /**
112
     * Seta o objeto `Customer` associado ao `Voucher`.
113
     *
114
     * @param Customer|null $customer
115
     * @return self
116
     */
117
    public function setCustomer(?Customer $customer = null): self
118
    {
119
        $this->set('customer', $customer);
120
        return $this;
121
    }
122
123
}