Attendee::getDob()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Ipag\Sdk\Model;
4
5
use Ipag\Sdk\Model\Schema\Mutator;
6
use Ipag\Sdk\Model\Schema\Schema;
7
use Ipag\Sdk\Model\Schema\SchemaBuilder;
8
9
/**
10
 * Attendee Class
11
 *
12
 * Classe responsável por representar o recurso Attendee.
13
 *
14
 */
15
final class Attendee extends Model
16
{
17
    /**
18
     *  @param array $data
19
     *  array de dados do Attendee.
20
     *
21
     *  + [`'document'`] string (opcional).
22
     *  + [`'dob'`] string (opcional) {Formato: `Y-m-d`}.
23
     */
24
    public function __construct(?array $data = [])
25
    {
26
        parent::__construct($data);
27
    }
28
29
    public function schema(SchemaBuilder $schema): Schema
30
    {
31
        $schema->string('document')->nullable();
32
        $schema->string('dob')->nullable();
33
34
        return $schema->build();
35
    }
36
37
    protected function dob(): Mutator
38
    {
39
        return new Mutator(
40
            null,
41
            function ($value, $ctx) {
42
                $d = \DateTime::createFromFormat('Y-m-d', $value);
43
44
                return is_null($value) ||
45
                    ($d && $d->format('Y-m-d') === $value) ?
46
                    $value : $ctx->raise('inválido');
47
            }
48
        );
49
    }
50
51
    /**
52
     * Retorna o valor da propriedade `document`.
53
     *
54
     * @return string|null
55
     */
56
    public function getDocument(): ?string
57
    {
58
        return $this->get('document');
59
    }
60
61
    /**
62
     * Seta o valor da propriedade `document`.
63
     *
64
     * @param string|null $document
65
     * @return self
66
     */
67
    public function setDocument(?string $document = null): self
68
    {
69
        $this->set('document', $document);
70
        return $this;
71
    }
72
73
    /**
74
     * Retorna o valor da propriedade `dob`.
75
     *
76
     * @return string|null
77
     */
78
    public function getDob(): ?string
79
    {
80
        return $this->get('dob');
81
    }
82
83
    /**
84
     * Seta o valor da propriedade `dob`.
85
     *
86
     * @param string|null $dob
87
     * @return self
88
     */
89
    public function setDob(?string $dob = null): self
90
    {
91
        $this->set('dob', $dob);
92
        return $this;
93
    }
94
95
}