Passed
Push — master ( c6882e...32aa44 )
by Adrien
06:46
created

AccountingDocument::getTransaction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

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
ccs 0
cts 2
cp 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Model;
6
7
use Doctrine\ORM\Mapping as ORM;
8
9
/**
10
 * A document attesting an expense claim
11
 *
12
 * @ORM\HasLifecycleCallbacks
13
 * @ORM\Entity(repositoryClass="Application\Repository\AccountingDocumentRepository")
14
 */
15
class AccountingDocument extends AbstractFile
16
{
17 3
    protected function getBasePath(): string
18
    {
19 3
        return 'data/accounting/';
20
    }
21
22 1
    protected function getAcceptedMimeTypes(): array
23
    {
24
        return [
25 1
            'image/bmp',
26
            'image/gif',
27
            'image/jpeg',
28
            'image/pjpeg',
29
            'image/png',
30
            'image/webp',
31
            'application/pdf',
32
            'application/x-pdf',
33
        ];
34
    }
35
36
    /**
37
     * @var ExpenseClaim
38
     *
39
     * @ORM\ManyToOne(targetEntity="ExpenseClaim", inversedBy="accountingDocuments")
40
     * @ORM\JoinColumns({
41
     *     @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
42
     * })
43
     */
44
    private $expenseClaim;
45
46
    /**
47
     * @var Transaction
48
     *
49
     * @ORM\ManyToOne(targetEntity="Transaction", inversedBy="accountingDocuments")
50
     * @ORM\JoinColumns({
51
     *     @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
52
     * })
53
     */
54
    private $transaction;
55
56
    /**
57
     * @param null|ExpenseClaim $expenseClaim
58
     */
59 7
    public function setExpenseClaim(?ExpenseClaim $expenseClaim): void
60
    {
61 7
        if ($this->expenseClaim) {
62 1
            $this->expenseClaim->accountingDocumentRemoved($this);
63
        }
64
65 7
        $this->expenseClaim = $expenseClaim;
66
67 7
        if ($this->expenseClaim) {
68 7
            $expenseClaim->accountingDocumentAdded($this);
0 ignored issues
show
Bug introduced by
The method accountingDocumentAdded() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

68
            $expenseClaim->/** @scrutinizer ignore-call */ 
69
                           accountingDocumentAdded($this);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
69
        }
70 7
    }
71
72
    /**
73
     * @return null|ExpenseClaim
74
     */
75 4
    public function getExpenseClaim(): ?ExpenseClaim
76
    {
77 4
        return $this->expenseClaim;
78
    }
79
80
    /**
81
     * @param null|Transaction $transaction
82
     */
83 1
    public function setTransaction(?Transaction $transaction): void
84
    {
85 1
        if ($this->transaction) {
86 1
            $this->transaction->accountingDocumentRemoved($this);
87
        }
88
89 1
        $this->transaction = $transaction;
90
91 1
        if ($this->transaction) {
92 1
            $transaction->accountingDocumentAdded($this);
0 ignored issues
show
Bug introduced by
The method accountingDocumentAdded() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

92
            $transaction->/** @scrutinizer ignore-call */ 
93
                          accountingDocumentAdded($this);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
93
        }
94 1
    }
95
96
    /**
97
     * @return null|Transaction
98
     */
99
    public function getTransaction(): ?Transaction
100
    {
101
        return $this->transaction;
102
    }
103
}
104