Failed Conditions
Push — master ( 8ca623...be032d )
by Sam
07:15
created

ExpenseClaim::accountingDocumentRemoved()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Model;
6
7
use Application\DBAL\Types\ExpenseClaimStatusType;
8
use Application\DBAL\Types\ExpenseClaimTypeType;
9
use Application\Traits\HasDescription;
10
use Application\Traits\HasName;
11
use Application\Traits\HasRemarks;
12
use Doctrine\Common\Collections\ArrayCollection;
13
use Doctrine\Common\Collections\Collection;
14
use Doctrine\ORM\Mapping as ORM;
15
use GraphQL\Doctrine\Annotation as API;
16
17
/**
18
 * An expense claim to be refunded to an user
19
 *
20
 * @ORM\Entity(repositoryClass="Application\Repository\ExpenseClaimRepository")
21
 * @ORM\AssociationOverrides({
22
 *     @ORM\AssociationOverride(
23
 *         name="owner",
24
 *         joinColumns=@ORM\JoinColumn(nullable=false)
25
 *     )
26
 * })
27
 */
28
class ExpenseClaim extends AbstractModel
29
{
30
    use HasName;
31
    use HasDescription;
32
    use HasRemarks;
33
34
    /**
35
     * @var string
36
     *
37
     * @ORM\Column(type="decimal", precision=7, scale=2)
38
     */
39
    private $amount;
40
41
    /**
42
     * @var Collection
43
     * @ORM\OneToMany(targetEntity="Transaction", mappedBy="expenseClaim")
44
     */
45
    private $transactions;
46
47
    /**
48
     * @var Collection
49
     * @ORM\OneToMany(targetEntity="AccountingDocument", mappedBy="expenseClaim")
50
     */
51
    private $accountingDocuments;
52
53
    /**
54
     * @var string
55
     *
56
     * @ORM\Column(type="ExpenseClaimStatus", length=10, options={"default" = ExpenseClaimStatusType::NEW})
57
     */
58
    private $status = ExpenseClaimStatusType::NEW;
59
60
    /**
61
     * @var string
62
     *
63
     * @ORM\Column(type="ExpenseClaimType", length=10, options={"default" = ExpenseClaimTypeType::EXPENSE_CLAIM})
64
     */
65
    private $type = ExpenseClaimTypeType::EXPENSE_CLAIM;
66
67
    /**
68
     * Constructor
69
     */
70 8
    public function __construct()
71
    {
72 8
        $this->transactions = new ArrayCollection();
73 8
        $this->accountingDocuments = new ArrayCollection();
74 8
    }
75
76
    /**
77
     * Set amount
78
     *
79
     * @param string $amount
80
     */
81 1
    public function setAmount(string $amount): void
82
    {
83 1
        $this->amount = $amount;
84 1
    }
85
86
    /**
87
     * Get amount
88
     *
89
     * @return string
90
     */
91
    public function getAmount(): string
92
    {
93
        return $this->amount;
94
    }
95
96
    /**
97
     * Set status
98
     *
99
     * @API\Input(type="ExpenseClaimStatus")
100
     *
101
     * @param string $status
102
     */
103 2
    public function setStatus(string $status): void
104
    {
105 2
        $this->status = $status;
106 2
    }
107
108
    /**
109
     * Get status
110
     *
111
     * @API\Field(type="ExpenseClaimStatus")
112
     *
113
     * @return string
114
     */
115 5
    public function getStatus(): string
116
    {
117 5
        return $this->status;
118
    }
119
120
    /**
121
     * Set type
122
     *
123
     * @API\Input(type="ExpenseClaimType")
124
     *
125
     * @param string $type
126
     */
127
    public function setType(string $type): void
128
    {
129
        $this->type = $type;
130
    }
131
132
    /**
133
     * Get type
134
     *
135
     * @API\Field(type="ExpenseClaimType")
136
     *
137
     * @return string
138
     */
139
    public function getType(): string
140
    {
141
        return $this->type;
142
    }
143
144
    /**
145
     * Notify the expense claim that a transaction was added
146
     * This should only be called by Transaction::setExpenseClaim()
147
     *
148
     * @param Transaction $transaction
149
     */
150 1
    public function transactionAdded(Transaction $transaction): void
151
    {
152 1
        $this->transactions->add($transaction);
153 1
    }
154
155
    /**
156
     * Notify the expense claim that a transaction was removed
157
     * This should only be called by Transaction::setExpenseClaim()
158
     *
159
     * @param Transaction $transaction
160
     */
161 1
    public function transactionRemoved(Transaction $transaction): void
162
    {
163 1
        $this->transactions->removeElement($transaction);
164 1
    }
165
166
    /**
167
     * Get the transactions created from this expense claim
168
     *
169
     * @return Collection
170
     */
171 1
    public function getTransactions(): Collection
172
    {
173 1
        return $this->transactions;
174
    }
175
176
    /**
177
     * Notify the expense that an accounting document was added
178
     * This should only be called by AccountingDocument::setExpenseClaim()
179
     *
180
     * @param AccountingDocument $document
181
     */
182 7
    public function accountingDocumentAdded(AccountingDocument $document): void
183
    {
184 7
        $this->accountingDocuments->add($document);
185 7
    }
186
187
    /**
188
     * Notify the expense that an accounting document was removed
189
     * This should only be called by AccountingDocument::setExpenseClaim()
190
     *
191
     * @param AccountingDocument $document
192
     */
193 1
    public function accountingDocumentRemoved(AccountingDocument $document): void
194
    {
195 1
        $this->accountingDocuments->removeElement($document);
196 1
    }
197
198
    /**
199
     * Get accounting documents
200
     *
201
     * @return Collection
202
     */
203 1
    public function getAccountingDocuments(): Collection
204
    {
205 1
        return $this->accountingDocuments;
206
    }
207
}
208