Completed
Push — master ( 842c53...e59924 )
by Joachim
14:33
created

Invoice::getState()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Loevgaard\DandomainFoundation\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Loevgaard\DandomainDateTime\DateTimeImmutable;
7
use Loevgaard\DandomainFoundation;
8
use Loevgaard\DandomainFoundation\Entity\Generated\InvoiceInterface;
9
use Loevgaard\DandomainFoundation\Entity\Generated\InvoiceTraits;
10
11
/**
12
 * @ORM\Entity()
13
 * @ORM\Table(name="loevgaard_dandomain_invoices")
14
 */
15
class Invoice implements InvoiceInterface
16
{
17
    use InvoiceTraits;
18
19
    /**
20
     * @var int
21
     *
22
     * @ORM\Id
23
     * @ORM\GeneratedValue
24
     * @ORM\Column(type="integer")
25
     **/
26
    protected $id;
27
28
    /**
29
     * @var string|null
30
     *
31
     * @ORM\Column(nullable=true, type="string", length=191)
32
     */
33
    protected $creditNoteNumber;
34
35
    /**
36
     * @var \DateTimeImmutable|null
37
     *
38
     * @ORM\Column(nullable=true, type="datetime_immutable")
39
     */
40
    protected $date;
41
42
    /**
43
     * @var bool|null
44
     *
45
     * @ORM\Column(nullable=true, type="boolean")
46
     */
47
    protected $isPaid;
48
49
    /**
50
     * @var int|null
51
     *
52
     * @ORM\Column(nullable=true, type="integer")
53
     */
54
    protected $number;
55
56
    /**
57
     * @var string|null
58
     *
59
     * @ORM\Column(nullable=true, type="string", length=191)
60
     */
61
    protected $state;
62
63
    /**
64
     * Populates a invoice based on the response from the Dandomain API
65
     *
66
     * See the properties here:
67
     * http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/OrderService/help/operations/GetOrder
68
     *
69
     * @param \stdClass|array $data
70
     * @return InvoiceInterface
71
     */
72
    public function populateFromApiResponse($data) : InvoiceInterface
73
    {
74
        $data = DandomainFoundation\objectToArray($data);
75
76
        $date = $data['date'];
77
        if ($date) {
78
            $date = DateTimeImmutable::createFromJson($date);
79
        }
80
81
        $this
82
            ->setCreditNoteNumber($data['creditNoteNumber'])
83
            ->setIsPaid($data['isPaid'])
84
            ->setNumber($data['number'])
85
            ->setState($data['state'])
86
            ->setDate($date)
87
        ;
88
89
        return $this;
90
    }
91
92
    /**
93
     * @return int
94
     */
95
    public function getId(): int
96
    {
97
        return (int)$this->id;
98
    }
99
100
    /**
101
     * @param int $id
102
     * @return Invoice
103
     */
104
    public function setId($id)
105
    {
106
        $this->id = $id;
107
        return $this;
108
    }
109
110
    /**
111
     * @return null|string
112
     */
113
    public function getCreditNoteNumber()
114
    {
115
        return $this->creditNoteNumber;
116
    }
117
118
    /**
119
     * @param null|string $creditNoteNumber
120
     * @return Invoice
121
     */
122
    public function setCreditNoteNumber($creditNoteNumber)
123
    {
124
        $this->creditNoteNumber = $creditNoteNumber;
125
        return $this;
126
    }
127
128
    /**
129
     * @return \DateTimeImmutable|null
130
     */
131
    public function getDate()
132
    {
133
        return $this->date;
134
    }
135
136
    /**
137
     * @param \DateTimeImmutable|null $date
138
     * @return Invoice
139
     */
140
    public function setDate($date)
141
    {
142
        $this->date = $date;
143
        return $this;
144
    }
145
146
    /**
147
     * @return bool|null
148
     */
149
    public function getisPaid()
150
    {
151
        return $this->isPaid;
152
    }
153
154
    /**
155
     * @param bool|null $isPaid
156
     * @return Invoice
157
     */
158
    public function setIsPaid($isPaid)
159
    {
160
        $this->isPaid = $isPaid;
161
        return $this;
162
    }
163
164
    /**
165
     * @return int|null
166
     */
167
    public function getNumber()
168
    {
169
        return $this->number;
170
    }
171
172
    /**
173
     * @param int|null $number
174
     * @return Invoice
175
     */
176
    public function setNumber($number)
177
    {
178
        $this->number = $number;
179
        return $this;
180
    }
181
182
    /**
183
     * @return null|string
184
     */
185
    public function getState()
186
    {
187
        return $this->state;
188
    }
189
190
    /**
191
     * @param null|string $state
192
     * @return Invoice
193
     */
194
    public function setState($state)
195
    {
196
        $this->state = $state;
197
        return $this;
198
    }
199
}
200