Failed Conditions
Push — master ( 51347b...4787ce )
by Adrien
08:37
created

AccountingDocument::getBasePath()   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 0
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 Doctrine\ORM\Mapping as ORM;
8
use GraphQL\Doctrine\Annotation as API;
9
10
/**
11
 * A document attesting an expense claim
12
 *
13
 * @ORM\HasLifecycleCallbacks
14
 * @ORM\Entity(repositoryClass="Application\Repository\AccountingDocumentRepository")
15
 * @ORM\Table(uniqueConstraints={
16
 *     @ORM\UniqueConstraint(name="unique_name", columns={"filename"})
17
 * })
18
 */
19
class AccountingDocument extends AbstractModel implements \Ecodev\Felix\Model\File
20
{
21
    use \Ecodev\Felix\Model\Traits\File;
22
23 3
    protected function getBasePath(): string
24
    {
25 3
        return 'data/accounting/';
26
    }
27
28
    /**
29
     * @var null|ExpenseClaim
30
     *
31
     * @ORM\ManyToOne(targetEntity="ExpenseClaim", inversedBy="accountingDocuments")
32
     * @ORM\JoinColumns({
33
     *     @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
34
     * })
35
     */
36
    private $expenseClaim;
37
38
    /**
39
     * @var null|Transaction
40
     *
41
     * @ORM\ManyToOne(targetEntity="Transaction", inversedBy="accountingDocuments")
42
     * @ORM\JoinColumns({
43
     *     @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
44
     * })
45
     */
46
    private $transaction;
47
48
    /**
49
     * @param null|ExpenseClaim $expenseClaim
50
     */
51 7
    public function setExpenseClaim(?ExpenseClaim $expenseClaim): void
52
    {
53 7
        if ($this->expenseClaim) {
54 1
            $this->expenseClaim->accountingDocumentRemoved($this);
55
        }
56
57 7
        $this->expenseClaim = $expenseClaim;
58
59 7
        if ($this->expenseClaim) {
60 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

60
            $expenseClaim->/** @scrutinizer ignore-call */ 
61
                           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...
61
        }
62 7
    }
63
64
    /**
65
     * @return null|ExpenseClaim
66
     */
67 3
    public function getExpenseClaim(): ?ExpenseClaim
68
    {
69 3
        return $this->expenseClaim;
70
    }
71
72
    /**
73
     * @param null|Transaction $transaction
74
     */
75 1
    public function setTransaction(?Transaction $transaction): void
76
    {
77 1
        if ($this->transaction) {
78 1
            $this->transaction->accountingDocumentRemoved($this);
79
        }
80
81 1
        $this->transaction = $transaction;
82
83 1
        if ($this->transaction) {
84 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

84
            $transaction->/** @scrutinizer ignore-call */ 
85
                          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...
85
        }
86 1
    }
87
88
    /**
89
     * @return null|Transaction
90
     */
91
    public function getTransaction(): ?Transaction
92
    {
93
        return $this->transaction;
94
    }
95
}
96