Event   A
last analyzed

Complexity

Total Complexity 15

Size/Duplication

Total Lines 195
Duplicated Lines 0 %

Importance

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

15 Methods

Rating   Name   Duplication   Size   Complexity  
A setVenue() 0 4 1
A setSubtype() 0 4 1
A __construct() 0 3 1
A getDate() 0 3 1
A setDate() 0 4 1
A schema() 0 11 1
A setType() 0 4 1
A getVenue() 0 3 1
A setTickets() 0 4 1
A getName() 0 3 1
A addTicket() 0 11 1
A getTickets() 0 3 1
A setName() 0 4 1
A getType() 0 3 1
A getSubtype() 0 3 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
 * Event Class
10
 *
11
 * Classe responsável por representar o recurso Event.
12
 *
13
 */
14
final class Event extends Model
15
{
16
    /**
17
     *  @param array $data
18
     *  array de dados do Event.
19
     *
20
     *  + [`'name'`] string (opcional).
21
     *  + [`'date'`] string (opcional).
22
     *  + [`'type'`] string (opcional).
23
     *  + [`'subtype'`] string (opcional).
24
     *
25
     *  + [`'venue'`] array (opcional) dos dados do Venue.
26
     *  + &emsp; [`'name'`] string (opcional).
27
     *  + &emsp; [`'capacity'`] int (opcional).
28
     *  + &emsp; [`'address'`] string (opcional).
29
     *  + &emsp; [`'city'`] string (opcional).
30
     *  + &emsp; [`'state'`] string (opcional).
31
     *
32
     *  + [`'tickets'`] array (opcional) dos dados do `Ticket`.
33
     *  + &emsp; [`'id'`] string (opcional).
34
     *  + &emsp; [`'category'`] string (opcional).
35
     *  + &emsp; [`'premium'`] bool (opcional).
36
     *  + &emsp; [`'section'`] string (opcional).
37
     *
38
     *  + &emsp; [`'attendee'`] array (opcional) dos dados do Attendee.
39
     *  + &emsp; &emsp; [`'document'`] string (opcional).
40
     *  + &emsp; &emsp; [`'dob'`] string (opcional) {Formato: `Y-m-d`}.
41
     */
42
    public function __construct(?array $data = [])
43
    {
44
        parent::__construct($data);
45
    }
46
47
    public function schema(SchemaBuilder $schema): Schema
48
    {
49
        $schema->string('name')->nullable();
50
        $schema->string('date')->nullable();
51
        $schema->string('type')->nullable();
52
        $schema->string('subtype')->nullable();
53
54
        $schema->has('venue', Venue::class)->nullable();
55
        $schema->hasMany('tickets', Ticket::class)->nullable();
56
57
        return $schema->build();
58
    }
59
60
    /**
61
     * Retorna o valor da propriedade `name`.
62
     *
63
     * @return string|null
64
     */
65
    public function getName(): ?string
66
    {
67
        return $this->get('name');
68
    }
69
70
    /**
71
     * Seta o valor da propriedade `name`.
72
     *
73
     * @param string|null $name
74
     * @return self
75
     */
76
    public function setName(?string $name = null): self
77
    {
78
        $this->set('name', $name);
79
        return $this;
80
    }
81
82
    /**
83
     * Retorna o valor da propriedade `date`.
84
     *
85
     * @return string|null
86
     */
87
    public function getDate(): ?string
88
    {
89
        return $this->get('date');
90
    }
91
92
    /**
93
     * Seta o valor da propriedade `date`.
94
     *
95
     * @param string|null $date
96
     * @return self
97
     */
98
    public function setDate(?string $date = null): self
99
    {
100
        $this->set('date', $date);
101
        return $this;
102
    }
103
104
    /**
105
     * Retorna o valor da propriedade `type`.
106
     *
107
     * @return string|null
108
     */
109
    public function getType(): ?string
110
    {
111
        return $this->get('type');
112
    }
113
114
    /**
115
     * Seta o valor da propriedade `type`.
116
     *
117
     * @param string|null $type
118
     * @return self
119
     */
120
    public function setType(?string $type = null): self
121
    {
122
        $this->set('type', $type);
123
        return $this;
124
    }
125
126
    /**
127
     * Retorna o valor da propriedade `subtype`.
128
     *
129
     * @return string|null
130
     */
131
    public function getSubtype(): ?string
132
    {
133
        return $this->get('subtype');
134
    }
135
136
    /**
137
     * Seta o valor da propriedade `subtype`.
138
     *
139
     * @param string|null $subtype
140
     * @return self
141
     */
142
    public function setSubtype(?string $subtype = null): self
143
    {
144
        $this->set('subtype', $subtype);
145
        return $this;
146
    }
147
148
    /**
149
     * Retorna o valor da propriedade `venue`.
150
     *
151
     * @return Venue|null
152
     */
153
    public function getVenue(): ?Venue
154
    {
155
        return $this->get('venue');
156
    }
157
158
    /**
159
     * Seta o valor da propriedade `venue`.
160
     *
161
     * @param Venue|null $venue
162
     * @return self
163
     */
164
    public function setVenue(?Venue $venue = null): self
165
    {
166
        $this->set('venue', $venue);
167
        return $this;
168
    }
169
170
    /**
171
     * Retorna o array `tickets` referente ao recurso `Event`.
172
     *
173
     * @return array|null
174
     */
175
    public function getTickets(): ?array
176
    {
177
        return $this->get('tickets');
178
    }
179
180
    /**
181
     * Seta o array `tickets` referente ao recurso `Event`.
182
     *
183
     * @param array|null $tickets
184
     * @return self
185
     */
186
    public function setTickets(?array $tickets = null): self
187
    {
188
        $this->set('tickets', $tickets);
189
        return $this;
190
    }
191
192
    /**
193
     * Adiciona um novo objeto `Ticket` ao recurso `Event`.
194
     *
195
     * @param Ticket $ticket
196
     * @return self
197
     */
198
    public function addTicket(Ticket $ticket): self
199
    {
200
        $this->set(
201
            'tickets',
202
            [
203
                ...$this->get('tickets'),
204
                $ticket
205
            ]
206
        );
207
208
        return $this;
209
    }
210
211
}