Failed Conditions
Push — master ( 276992...d29638 )
by Adrien
06:52
created

ExpenseClaim   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 147
Duplicated Lines 0 %

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 147
rs 10
c 0
b 0
f 0
ccs 25
cts 30
cp 0.8333
wmc 11

11 Methods

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